Open Closed

Duplicate tables in migrations from different modules #8735


User avatar
0
bmulinari created
  • 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)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, can you please check this answer and see if it answers your question?

  • User Avatar
    0
    rcalv002 created

    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.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    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.

  • User Avatar
    0
    bmulinari created

    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!

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    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.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    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.

  • User Avatar
    0
    bmulinari created

    Hi! I apologize for the broken link. I've shared a new by mail.

    Let me know if you need anything.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    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.

  • User Avatar
    0
    rcalv002 created

    Hello, your feedback please.

  • User Avatar
    0
    rcalv002 created

    Hello. Your feedback please

  • User Avatar
    0
    rcalv002 created

    This ticket has been open over 2 weeks, we would appreciate some feedback

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    This ticket has been open over 2 weeks, we would appreciate some feedback

    Hi, sorry for the late response. I will write you back soon.

    Regards.

  • User Avatar
    0
    rcalv002 created

    Hello, Can we get this support ticket that's been open for 3 weeks transferred to another support rep?

  • User Avatar
    0
    rcalv002 created

    Support, please support.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    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.

  • User Avatar
    0
    bmulinari created

    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.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    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.

  • User Avatar
    0
    bmulinari created

    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.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    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.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 01, 2025, 08:37