EF 7 Migration to Existing Database

后端 未结 3 1084
野趣味
野趣味 2021-02-06 00:11

I am working on a web project using ASP.Net 5 and EF7.

I have imported all the tables from existing database onto my models in my project. However, I am having problems

3条回答
  •  感动是毒
    2021-02-06 01:02

    In EF6 you would run a migration with the -IgnoreChanges flag and it would take a snapshot of the model without any Up() code. This is missing from EF 7(EF Core) as indicated here.

    The workaround for now is delete or comment out the code for existing database objects from the Up() code of the migration and then update-database. Subsequent migrations will then include only the changes.

提交回复
热议问题