在使用Entity Framework 4.3的Code First Migrations时,我得到了几个未处理的异常.
数据库上下文:
public class MyAppContext : DbContext
{
public DbSet<Branch> Branches { get; set; }
public MyAppContext()
{ }
}
Run Code Online (Sandbox Code Playgroud)
实体:
public class Branch : IEntity<Guid>
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool Active { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
数据库初始化程序:
public class MyAppInitializer : CreateDatabaseIfNotExists<MyAppContext>
{
protected override void Seed(MyAppContext context)
{
context.Branches.Add(new Branch() { Id = branchId, Name …Run Code Online (Sandbox Code Playgroud)