Update-database -force Command Is Not Updating The Base In Entity Framework Code -first
Solution 1:
Using an Existing Database
Depending on the state of your context you need to the one of the following...
IF YOUR DATABASE CONTEXT CONTAINS ONLY YOUR EXISTING TABLES AND NO CUSTOM CHANGES DO THE FOLLOWING
Add-Migration Initial-IgnoreChanges
This will create a blank migration script
update-database
This will update the database to this migration but no changes will be applied. You can now add your changes to the database context. After you have finished do the following
Add-Migration Custom
This will generate a migration script with your changes in it. Then update your database again.
update-database
IF YOUR DATABASE CONTEXT CONTAINS YOUR EXISTING TABLES AND ALSO YOUR CUSTOM CHANGES
Add-migration InitialThis generates a migration script. Go through the migration script and remove any references to existing tables in both the UP and DOWN methods. You will be left with a script which only includes your custom logic.
update-database
Hope this helps!

Post a Comment for "Update-database -force Command Is Not Updating The Base In Entity Framework Code -first"