如果我运行在包管理器控制台下面的代码:实体Framwork的Code First迁移
-Update-Database -Force
除了运行一些默认的数据表,我还以为所有的表被清洁的种子法之前,但这似乎是不正确的!?
编辑:
我还是觉得很奇怪,为什么在数据库中的表,当我运行-update数据库-force没有DROP掉,如果他们不这样做呢?为什么每次运行-update-database时,使用Seed方法添加的数据都会继续添加数据。再次,不应该prevoius添加的数据被覆盖?当我从ASP.NET这个链接和其他来源阅读下面的文本看起来应该有可能用新数据播种,旧数据或表应该被丢弃!?我是否误解了这一点,或者我做错了什么?
You have configured the Entity Framework to automatically drop and
re-create the database each time you change the data model. When you
add, remove, or change entity classes or change your DbContext class,
the next time you run the application it automatically deletes your
existing database, creates a new one that matches the model, and seeds
it with test data.
如果你删除数据库,你应该有一个初始化程序集来创建一个新的程序 – Ortund
@Ortund我是ASP.NET MVC的新手,在研究过程中的以前的项目中,我记得刚刚删除了DB,然后键入一些命令或它是由Visual Studio创建的,但我可能是错的?你是什么意思与初始化? –
我会在一个答案中解释,但你不需要接受它,除非它工作 – Ortund