Click here to Skip to main content
15,921,716 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Helllo Team ,

I am Creating Application Using Asp core with Code-first Approach.

I have Created 2 models like -User, Department then I did migration and that was successfully migrated at very first time, but after that when I create a new model like :-Category and want to migrate then I am getting the error below issue.

"There is already an object named 'TableName' in the database."


It's coming if I do migration again and again when I add New model 


What I have tried:

I have tried but not successful.
Posted
Updated 15-Oct-19 19:32pm
v2
Comments
Richard MacCutchan 9-Oct-19 7:33am    
Inspect your database to see why it contains that object.
Member 14604346 9-Oct-19 10:31am    
Hi Richard, getting it when I do subsequent migration, not in the first time.

1 solution

Hi
if you created new migration after created category model for updating database then may be this error showed.

Try to run below command in package manager console:
dotnet ef database update

Hope this will help you.
Thank you.
 
Share this answer
 

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