EF - Code first - update database after model changes

asp.net-core-2.0 asp.net-web-api entity-framework-core

Question

I created a web api application in .net core 2.0 and I create my database using code first approach and using the commands add-migration , update-database

Now I made some changes in my model classes and created a new migration using add-migration 2ndMigration command. It created the migration with Up and Down methods. When I try to update database with this migration it gives me an error that

Table 'TableName' already exists.

There's no create table command in the migration.

Why I'm seeing this error? or what's the command I need to run to update the database?

1
0
9/18/2017 12:53:50 AM

Popular Answer

run Add-Migration Initial -IgnoreChanges -ConfigurationTypeName YourDbConfigurationName and add -force if needed.

After that use your regular Update-database line.

1
3/21/2018 4:10:14 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow