Click here to Skip to main content
15,886,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using Entity framework and code first approach in my project. I have done some Migrations to my server database and it was working fine. now I added a few more tables and try to create a migration by `add-migration` command to the database on server.

The command runs with no error and created a migration file.

But, when I check the migration file the code in the migration file was to create all tables again to database (`create table` for already created tables are also in the up method).

When I run `Update-database` command it returned an error saying

table already exist in database.

I try it on some local database on my system and it was working fine.

Can anyone help me with this?

Is there any special permission to set in the server?

Is it because some services from visual studio getting blocked? If so how can I solve it?

What I have tried:

I check the database . It is same and __MigrationHistory table have previous data .only the migration file creation has the issue. When I created a migration file and edit it properly the update-database works. I suspect there is some service which compare both database and entity to find the difference and some how it is getting blocked. But I have no idea about such a process.
Posted
Updated 4-Jul-18 0:57am
v2
Comments
[no name] 26-Jun-18 12:39pm    
Is there "data" in the database you need to keep?

If not, delete the tables and "create" instead of trying to migrate.
Jinto Jacob 27-Jun-18 0:03am    
I need to keep the data in Database
F-ES Sitecore 4-Jul-18 7:06am    
Don't use code first then, use database first. Code first is not for anything beyond basic prototyping apps.
Nitin S 4-Jul-18 7:27am    
delete the migration file and generate it again
Jinto Jacob 4-Jul-18 7:29am    
tried. but no success.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900