[英]How do I create a new migration each time I update the database with Entity Framework
In my dbo.__MigrationHistory
table from my Entity Framework database I have 3 entries: 在我的Entity Framework数据库的
dbo.__MigrationHistory
表中,我有3个条目:
201708082015111_InitialCreate
201708082017162_Initial
201708082046380_AutomaticMigration
but in the project itself, I have just one migration file: 但是在项目本身中,我只有一个迁移文件:
201708082017162_Initial.cs
I was thinking to delete the database and start over. 我正在考虑删除数据库并重新开始。
My main focus is how to create migration files each time I update the database from package console. 我的主要重点是每次从程序包控制台更新数据库时如何创建迁移文件。 For example, I create another model (therefore, another entity in my schema), so I want to run
Update-Database
and create a migration file in C# at the same time containing information about the updated schema (with the new table...). 例如,我创建了另一个模型(因此在我的架构中是另一个实体),因此我想运行
Update-Database
并同时在C#中创建一个迁移文件,其中包含有关更新的架构的信息(以及新表...) )。
因此,我通过应用以下程序使其工作: Add-Migration migx
,然后运行Update-Database -verbose
然后,我检查了__MigrationHistory表,并注意到已应用201708082108002_migx。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.