-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrations not created correctly #7196
Comments
I can reproduce something similar. I have 3 DBContext classes in my project. when i perform (via PMC scaffold) The only thing I changed in the domain entity was add the FeeValueId column so the resulting migration should have been:
Is it safe to just delete the erroneous create table or does that mess up the changes made to the snapshot? |
Creating a second migration and then calling Note Running Sapient MySQL and not sure how much of this logic is maintained in the core repo and what reside in Sapient. |
@joacar could you share the model classes (or project) so that we can try to reproduce this. Migrations should use the ModelSnapshot.cs file that it generates to work out what changes since the last migration (rather than recreating the whole schema). I guess also just check that you didn't delete/move the snapshot file 😄. And to answer a couple of your questions...
Scripting doesn't pay any attention to the database. It creates a script based on the migrations you specify. This is because scripting is generally used to get a script to apply to a production database.
You can just use the short name (without the timestamp) when you run commands. |
@Allann your issue seems to be different from the one being discussed here, so probably best to open a new issue. That said, I'm guessing types in one context have references to types in the other contexts? If so, they will get included in the model, and therefore in the migrations too. Take a look at #2725 for some discussion - and a feature we are planning that will help with this scenario. |
Same issue @joacar reported. **Tech details **: |
@ElLinn This is a closed issue from a long time ago. Please open a new issue and include a small, runnable project/solution or complete code listing that demonstrates the behavior you are seeing. |
Steps to reproduce
dotnet ef migrations add initial && dotnet ef database update
dotnet ef migrations add new_column
dotnet ef database update && dotnet ef database update
The issue
Get error message table '<model>' already exists. Inspecting the file
<datetime>_new_column.cs
reveals the answer - it tries to create the table again instead of just creating the correct alter command.Side note: It would be better the have the 'migration name' pre-pended to the generated migration file since it would make it easier to work using the command line.
Further technical details
EF Core version: 1.1.0
Operating system: macOS Sierra 10.12.1
Visual Studio version: Visual Studio preview for Mac
MySQL version: 5.6.10
MySQL adapter: Sapient
Other details about my project setup:
The text was updated successfully, but these errors were encountered: