question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scaffolding - There is already an object named 'entity_name' in the database.

See original GitHub issue

Hi,

I read though the documentation in https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/ and created a code first initial migration using PowerShell command (Add-Migration). This step generated three files -

  • TimeStamp_Initial.cs
  • TimeStamp_Initial.Designer.cs
  • DbContextModelSnapshot.cs

I was able to successfully apply the migration to the database. Then I added a new entity and tried generating another migration. This step updated the DbContextModelSnapshot.cs file and produced two new files -

  • TimeStamp_Update.cs
  • TimeStamp_Update.Designer.cs

I then tried to apply the migrations but received an error. When I looked at the Up method in TimeStamp_Update.cs, I see the newly added table along with existing (all) tables that we created in the initial migration. Is this the expected behavior? Should I be manually removing the tables that are already existing in the database from the Up method? May be I’m missing something, kindly guide…

Exception message: There is already an object named 'entity_name' in the database.

Further technical details

EF Core version: 2.0.2
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10
IDE: Visual Studio 2017 15.6.6

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

38reactions
kiran-mahadevcommented, Apr 18, 2018

I figured out the issue… Closing 😃

11reactions
ajcvickerscommented, Oct 5, 2020

@ruwentos This is a closed issue. If you’re hitting an issue, then please open a new issue and attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate.

Read more comments on GitHub >

github_iconTop Results From Across the Web

There is already an object named in the database
The value of this column is based on your namespace . for example is " DataAccess.Migrations.Configuration ". When you change the namespace, it ......
Read more >
There Is Already an Object Named in the Database Fixes
You can fix the there is already an object named in the database by renaming the new object, updating a database using EF,...
Read more >
There is already an object named 'Books' in the database.
Hello "dotnet ef database update" causes "There is already an object named 'Books' in the database." DB connection in program.cs:
Read more >
There is already an object named 'AspNetRoles' in ... - YouTube
In this video, I am going to fix this exception in asp.net core. Fix: There is already an object named 'AspNetRoles' in the...
Read more >
T-SQL CREATE VIEW returning 'There is already an object ...
Can successfully create a view with a '2' appended into the target database. It's just when the view name is the same as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found