- ABP Framework version: v9.0.0
- UI Type: Blazor Server
- Database System: EF Core (SQL Server)
- Steps to reproduce the issue:
Hi! We are having an issue with Entity Framework migrations in our solution which consists of an application and multiple custom modules. Each module has its own DbContext, like in the approach shown here. It's worth pointing out that we are using a separate database for the tenant.
To put it simply, here's the issue we are facing:
- Module A creates Table_A
- Migration correctly adds Table_A
- Module B creates Table_B, which has a relationship to Table_A (one-to-many)
- Migration incorrectly tries to add Table_A again, in addition to Table_B
This obviously results in the error "Table_A already exists" when running the migrator. I'm not sure what we are doing wrong, but we tried a bunch of different things and the migration for Table_B is always wrong (it shouldn't try to recreate Table_A).
Any help is appreciated. Thanks!
19 Answer(s)
-
0
Hi, can you please check this answer and see if it answers your question?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hello, Negative, the issue is at the moment of generating migration it includes in the up code a table that was already in previous migration up code. The issue is not at the moment of applying migration as far as I can see.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hello, Negative, the issue is at the moment of generating migration it includes in the up code a table that was already in previous migration up code. The issue is not at the moment of applying migration as far as I can see.
Hi, by any chance, can you share your application via email (to support@abp.io with the ticket number), so I can better assist you.
Regards.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi, @EngincanV. As requested, I've sent the application code and added a bit of context to the issue mentioned here.
Let me know if you need anything else, thanks!
Thank you, I got your project. I will examine it and try to write you back asap.
Regards.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi, @EngincanV. As requested, I've sent the application code and added a bit of context to the issue mentioned here.
Let me know if you need anything else, thanks!
Hi again @bmulinari, I'm trying to download the application but it says "page not found" when clicking to the link and providing the password. Can you please check it and let me know about the final status?
Regards.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi! I apologize for the broken link. I've shared a new by mail.
Let me know if you need anything.
Hi, thanks for updating the link. I will examine your project today and write back to you asap.
Regards.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
-
0
Support, please support.
Hi, since the question was asked by @bmulinari and you have added the last response, questions become invisible from our dashboard. This is the reason why we could not prioritize to answer this question. Sorry for the late response.
@bmulinari can you please send the project again, because when I try to download the application, it gives a 502 bad gateway error? I have reviewed it before but I could not find it in my workspace for now.
I will prioritize it and will fix your problem when you send your email. So, please let me know.
Regards.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Support, please support.
Hi, since the question was asked by @bmulinari and you have added the last response, questions become invisible from our dashboard. This is the reason why we could not prioritize to answer this question. Sorry for the late response.
@bmulinari can you please send the project again, because when I try to download the application, it gives a 502 bad gateway error? I have reviewed it before but I could not find it in my workspace for now.
I will prioritize it and will fix your problem when you send your email. So, please let me know.
Regards.
@EngincanV, I have sent the e-mail again with the code.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Support, please support.
Hi, since the question was asked by @bmulinari and you have added the last response, questions become invisible from our dashboard. This is the reason why we could not prioritize to answer this question. Sorry for the late response.
@bmulinari can you please send the project again, because when I try to download the application, it gives a 502 bad gateway error? I have reviewed it before but I could not find it in my workspace for now.
I will prioritize it and will fix your problem when you send your email. So, please let me know.
Regards.
@EngincanV, I have sent the e-mail again with the code.
Hi, thanks for sharing your project. I have sent an email to you with a solution to your problem:
Please check your mail and let me know if you need further assistant. Regards.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi, @EngincanV thanks for the response.
I tested the change with the steps you mentioned and it did work, that is, the table created in the previous module is no longer created again in the migration for the new module.
However, I noticed that this only worked when I ran the command to remove the latest migration twice (as you instructed), and as expected that removes the last two migrations, even though the second to last migration it removes has no relation to the latest one or its tables. I don't understand why that is the case, could you please provide an explanation?
Thanks in advance.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi, @EngincanV thanks for the response.
I tested the change with the steps you mentioned and it did work, that is, the table created in the previous module is no longer created again in the migration for the new module.
However, I noticed that this only worked when I ran the command to remove the latest migration twice (as you instructed), and as expected that removes the last two migrations, even though the second to last migration it removes has no relation to the latest one or its tables. I don't understand why that is the case, could you please provide an explanation?
Thanks in advance.
Hi, sometimes when adding a new migration there might occur some sync problems between following migrations (due to old assemblies, even the command build the efcore project still some assemblies may old assemblies for example) and it seems this was the case in your example, because your configuration was right.
So by reverting the last two migration, you have sync the migrations and so the efcore could generate a new migration from the right point and sync itself.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
