Click here to Skip to main content
14,330,663 members
Rate this:
Please Sign up or sign in to vote.
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 2 days ago
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100