Open Closed

No db migrations for Entities in Modules #9011


User avatar
0
viktor created

We are using ABP Studio + ABP Suite to generate Entities. We created Main and one [Module1]. We di install Module into Main.
After, using Abp Suite we select [Module1] and created new entity. But no Migration was generated to apply on database level.

How to generate db migrations for new entities of [Module1]. We plan to add/use more Modules and make complex entities including Navigations and Master-child. So ABP Suite was very helpful tool.


6 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi,

    While you developing a Module, you shouldn't create migrations inside module since it's re-usable project that can be consumed by multiple applications. You should create migrations in your end application that consumes your module.

    You can call builder.ConfigureModule1(); extension method in your application's DbContext to configure entities from your module and then create migrations in application. If you created DDD Module while creating it, there should already be Module1DbContextModelCreatingExtensions.cs and you can configure your entities there, you can configure entities from module in that extension method nad use it wherever you use use that module like any other ABP modules.

  • User Avatar
    0
    viktor created

    Hi, enisn
    I am not creating migrations. We are using ABP Studio + ABP Suite. I hope it will help to understand our goal: we want to use ABP Suite for creating Entities to be sure all needed code will be generated properly.

    Below steps to reproduce issues:

    1. ABP Studio - New Solution [DemoSolution]: Angular LeptonX + EF + SQLite (in prod scenario we will use SQL) + Multi-Tenancy

    2. Solution Created. Build. Run. Works.

    3. ABP Studio - New Module [FirstModule] - DDD Module.

    4. ABP Studio - [DemoSolution] -> Import Module + Install. Graph Build. Run. Ok.
      And now we want to add new Entites to [FirstModule] module. So:

    5. ABP Suite - version 9.1.0. Selecting FirstModule
      image.png

    6. Add new Master Entity - [Product] with one property [Title]. Save and Generate. Ok, no errors.
      image.png
      Also I can see [FirstModule] under permissions, and I did grant permissions to admin role. Ok, no errors.
      image.png

    Issue 1 >> I can not find any tables in database. There are no any migrations files create so I can not run dotnet ef migrations list or update database.
    image.png

    Issue 2 >> I can not see [FirstModule] itself on Angular UI. How to manage (CRUD) Product?
    image.png

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, enisn
    I am not creating migrations. We are using ABP Studio + ABP Suite. I hope it will help to understand our goal: we want to use ABP Suite for creating Entities to be sure all needed code will be generated properly.

    Below steps to reproduce issues:

    1. ABP Studio - New Solution [DemoSolution]: Angular LeptonX + EF + SQLite (in prod scenario we will use SQL) + Multi-Tenancy

    2. Solution Created. Build. Run. Works.

    3. ABP Studio - New Module [FirstModule] - DDD Module.

    4. ABP Studio - [DemoSolution] -> Import Module + Install. Graph Build. Run. Ok.
      And now we want to add new Entites to [FirstModule] module. So:

    5. ABP Suite - version 9.1.0. Selecting FirstModule
      image.png

    6. Add new Master Entity - [Product] with one property [Title]. Save and Generate. Ok, no errors.
      image.png
      Also I can see [FirstModule] under permissions, and I did grant permissions to admin role. Ok, no errors.
      image.png

    Issue 1 >> I can not find any tables in database. There are no any migrations files create so I can not run dotnet ef migrations list or update database.
    image.png

    Issue 2 >> I can not see [FirstModule] itself on Angular UI. How to manage (CRUD) Product?
    image.png

    Hi, did you check our Modular Monolith Development Tutorial?. In that tutorial, we are explaining important points that you may want to check.

    Currently, we also preparing its Angular UI version. To see the related menu items for now, you should write some codes, as mentioned https://github.com/abpframework/abp/issues/20827#issuecomment-2624232973

    Please check the tutorial and the issue comment to see if it fixes your problem. Regards.

  • User Avatar
    0
    viktor created

    Hi, EngincanV
    Yes, we read this tutorial. But how it is related? You did not answer about migration files? how can we generate migrations for new Entities which are created in Modules? Is it some bug or it should be done always manually? If it is manual process, so what is then reason to pay for Suite... a lot of logic will be in Modules.

    And, yes we did changes mentioned in #20827, with some fixes in generated code it's working now.

    Awaiting answer on first issue.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, first of all, thanks for the quick reply. Great to hear that, the code is working now. For the first question:

    You did not answer about migration files? how can we generate migrations for new Entities which are created in Modules? Is it some bug or it should be done always manually? If it is manual process, so what is then reason to pay for Suite... a lot of logic will be in Modules.

    ABP Suite creates migrations and applies them to most of the templates. However, for the module templates, since ABP Suite can't know, which module has relation to which main solution, it's hard to get the migration folder and apply it. So, only for the module template, you should create migrations manually, yes.

  • User Avatar
    0
    viktor created

    Hi, EngincanV
    But I am talking about DB migrations. Suite knows Entity and all relations within one module (and there are no cross-module entities relations). So why it can not generate db migrations? Is it plans for such in future?
    We are building solution to separate some business logic in different modules, so a lot of new Entities are planned inside Modules, and to build always manually it would be a lot of operational risks.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 20, 2025, 18:00