我安裝了最新版本的Windows 10(秋季創建者更新)和Visual Studio 2017(15.4)。UWP SQL Server遷移不起作用
我創建了針對主要版本和安裝的NuGet一個UWP應用:
- microsoft.entityframeworkcore.tools
- microsoft.entityframeworkcore.sqlserver
這是我的代碼:
[Table("tbProva")]
public class Prova
{
public Prova()
{
Indirizzi = new List<Indirizzo>();
}
[Key]
public Guid Id { get; set; }
[MaxLength(250)]
public string Nome { get; set; }
public ICollection<Indirizzo> Indirizzi { get; set; }
}
public class ProvaConfig : IEntityTypeConfiguration<Prova>
{
public void Configure(EntityTypeBuilder<Prova> builder)
{
builder.HasMany(c => c.Indirizzi)
.WithOne(c => c.Prova)
.HasForeignKey(c => c.IdProva)
.OnDelete(DeleteBehavior.Cascade);
}
}
[Table("tbIndirizzi")]
public class Indirizzo
{
[Key]
public Guid Id { get; set; }
[MaxLength(250)]
public string Strada { get; set; }
[MaxLength(10)]
public string Civico { get; set; }
public Prova Prova { get; set; }
public Guid IdProva { get; set; }
}
public class DcContext : DbContext
{
public DbSet<Prova> tbProva { get; set; }
public DbSet<Indirizzo> tbIndirizzi { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("Server=Europa;Database=ProvaDb;Trusted_Connection=True;");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration<Prova>(new ProvaConfig());
}
}
如果我運行遷移,我得到這個結果:
PM> Add-Migration poi
System.TypeLoadException:非èstato不可能性caricare IL TIPO 'System.Globalization.CultureInfo' dall'assembly 'System.Runtime,版本= 4.0.0.0,文化=中性公鑰= b03f5f7f11d50a3a'。
如果我從模型中刪除導航屬性,我不覆蓋OnModelCreating
,它工作正常。
感謝
請確保始終翻譯錯誤消息。我們並不全都說你的母語:-) – Wndrr
好的。 System.TypeLoadException:無法通過System.Runtime,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a程序集加載'System.Globalization.CultureInfo'類型程序集 – Kraken