locked
package manager console help needed using visual studio 2019 RRS feed

  • Question

  • User-945256609 posted

    When I run the following command in package manage console(VS 2019). I get the following error.

    Add-Migration InitialMigration
    The name 'InitialMigration' is used by an existing migration.
    PM>

    can somebody throw light on this? I am trying to use one project which was used in other machine to learn and tweak this project. Actually this command need to sync database schema and application model classes. At the moment my project doesn't have db - i only have VS files project which was taken from other machine.

    i know basic C#, asp.net and a bit of asp.net core.

    Cheers

    Sathya

    Thursday, April 30, 2020 1:59 PM

All replies

  • User475983607 posted

    sathyaav

    When I run the following command in package manage console(VS 2019). I get the following error.

    Add-Migration InitialMigration
    The name 'InitialMigration' is used by an existing migration.
    PM>

    can somebody throw light on this? I am trying to use one project which was used in other machine to learn and tweak this project. Actually this command need to sync database schema and application model classes. At the moment my project doesn't have db - i only have VS files project which was taken from other machine.

    i know basic C#, asp.net and a bit of asp.net core.

    The migration name must be unique.   Clearly, there is already a migration named "InitialMigration".   As the error clearly states you must use a unique migration name.

    Since you moved the code to a new machine, you need to decide if you are plan to use the same database or create a new database.   Generally, a local DB when learning EF Core and in some cases development.  All you have to do is update the database connection string to point to the server where you want the database created.   Next enter Update-Database in the package manager to create the database using the existing migration found in the project.

    Thursday, April 30, 2020 2:20 PM
  • User-945256609 posted

    many thanks. Update-Database InitialMigration worked.

    Thursday, April 30, 2020 2:45 PM