This article is a mirror article of machine translation, please click here to jump to the original article.

View: 25483|Reply: 0

[Source] Table 'xxx' already exists error when migrating to EntityFramework Core

[Copy link]
Posted on 11/19/2019 1:01:20 PM | | | |
In the .NET Framework version, assuming that the database already exists, this can be solved by creating a new empty migration file.
Before EF Core, there were many commands for migration, and when the migration occurred, we could solve it by using the command how:


Update your database with Code First migration
https://www.itsvse.com/thread-4827-1-1.html
(Source: Architect_Programmer)
However, in EF Core there are only two commands for migration:





When we first initialize the migration, the table structure is fully generated to initialize the table by dotnet ef migration add initial, and the next time we do the migration, this or that unintentional operation will result in the following results

Table 'account' already exists


The following is the migration file for the first initialization, as follows:

In order to solve the above problems, the premise is that the original migration files are still there, and we need to delete all the data in the Up method, while the data in the Down method can be deleted or not







Previous:Deliberately spending money to register, the resources to be spent are simply deceptive
Next:Sparklite-Sparklite-v1.2.16
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com