我正在使用代码首次迁移.在构建新的迁移之前,有没有办法在包管理器控制台中显示挂起的模型更改?
我正在使用实体框架6,我正在使用迁移.我已经使用初始迁移创建了数据库.现在我已对模型进行了更改并且上下文已更改,我想更新数据库但是......当我再次尝试运行Database-Update命令时,种子也在运行,这会因为某些数据再次插入而导致错误.
Update-Database不运行种子方法的情况下运行命令?很难相信EF没有任何简单的选择-No-Seed.其他ORM的确如此安全.
seed method我的应用程序的迁移文件夹中的主要用途是什么?在我的Configuration.cs文件中,我在种子方法中得到了这个 -
protected override void Seed(TestApplication.DataBaseContext.AppDBContext context)
{
// This method will be called after migrating to the latest version.
// You can use the DbSet<T>.AddOrUpdate() helper extension method
// to avoid creating duplicate seed data. E.g.
//
// context.People.AddOrUpdate(
// p => p.FullName,
// new Person { FullName = "Andrew Peters" },
// new Person { FullName = "Brice Lambson" },
// new Person { FullName = "Rowan Miller" }
// );
//
SeedMemebership();
} …Run Code Online (Sandbox Code Playgroud)