There Is Already An Object Name in the Database:

Most of the time developers use identity framework and enable migration in Asp Dot Net MVC Entity Framework or in Asp Dot Net Core Mvc and add migration in the database using the code first approach. The error comes because there is already an object named ‘aspnetroles’ in the database.

There is already an object name ‘Admin’ in the database.

We find solutions that work 100% Depends on you when you follow all these steps:

Follow These Steps:

  1. Open Package Manager Console.
  2. Add-Migration Migration-Name
  3. Update-Database

An Error Comes There is Already an Object Name “Admin in the Database” as Shown in the Video Watch This Video below to solve this error:

  • First “Drop-Database” Command in Package Console Manager
  • After Database Is Dropped. Go to the Models folder and find the table/Class Which is shown in the error. As in My Case Admin Appear.
  • Rename this Table/Class Name and Add ‘s’ At the end of the name as I do.
  • Then a pop-up Appears.
  • Click on “Yes”.
  • Then Go To The “Database Context Class” and find the “DBSET” that you have renamed.
  • Confirmed that The Name is the Same. As in My Case Public Dbset<Admins> Admin {Get;Set;}

Now add Do the migration Again

  • Add-Migration RemoveErrors
  • Update-Database
  • That’s it Error is Gone forever.

If you find this site useful please share it with your friends.


Leave a Comment