简体   繁体   中英

Entity Framework: How to disable model compatibility check in Code First Migrations

I would like to create a database initializer that runs all the pending migrations regardless of whether the model is in the correct state or not. Ie I want the initializer to run all the migrations even if it thinks the model state has changed since generating the migration so that it doesn't through the following error:

Unable to update database to match the current model because there are pending changes and automatic migration is disabled.

Does anyone know how I might get this to work?

Turn on automatic migrations. The error says that it cannot get your database in sync with your code because your classes contains changes which are not in any of your code based migrations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM