Error Happened when Update Database Using EF Core

I add a new migration to my solution , and when trying to update database using this command


there is an error message shown

There is already an object named 'Currency' in the database

I'm using Entity Framework Core 2.0

1 answer

  • answered 2018-01-14 08:17 Ehsan Ullah Nazir

    As error says

    Someone added already added an object Currency in DB

    Seems there is a problem in migration process.

    You can try following solution if they helps.

    Run add-migration command in "Package Manager Console":

    Add-Migration First -IgnoreChanges

    do some changes, and then update database from "Initial" file:

    Update-Database -verbose

    If you are working on a Team Project. I will suggest you to set AutomaticMigrationsEnabled to false

    AutomaticMigrationsEnabled = false;

    It will ensure unpredictable migrations and make sure that every developer on the team works with the same data base structure.

    You can also try

    Update-Database -Script for update a database manually. And you can exclude 'Currency' from resulting script