Open Closed

Create a new migration for separate module #4838


User avatar
0
selwade created

Dears,

I created an application with the name 'Main' then I added a new Module with the name 'Sub', then I generated a new entity in module 'Sub' using abp suite, generated the angular components, added the DTO, entities, etc.

What I am trying to do is:

Add a new migration for the Sub/Entity since the abp suite is not adding the migrations.

How to do it keeping Module Sub isolated from the main application.

Thanks in advance.

  • ABP Framework version: v7.0.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes

11 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Add a new migration for the Sub/Entity since the abp suite is not adding the migrations.

    You can run the dotnet ef migrations add xxx command to add a new migration file.

    How to do it keeping Module Sub isolated from the main application.

    Do you mean that you want the module as a standalone application? if so, you can run the HttpApi.Host project, it will be used as an independent API service.

    If I misunderstand please let me know.

  • User Avatar
    0
    selwade created

    Thank you for your response, where should I run mentioned command ?

    I think I didn't explain my issue well.

    I need to use the module as a part of any solution I make and I need the migrations to be a part of it.

    Thanks

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    If you configure the module dependency correctly, you can run the command in EntityFrameworkCore of the main application.

    I need to use the module as a part of any solution I make and I need the migrations to be a part of it.

    It is already there. you can use the module in any solution. there are two ways:

    • Referenced by project source code

    This way, you need to copy the modue source code always when you start a new solution.

    • Referenced by nuget package

    You can push the module to your private Nuget server, and install them to the solution, just like we do:

  • User Avatar
    0
    selwade created

    Hello Liang, Since I am using the abp suite, I think the configuration should be correct cause I am not the one who configured it.

    Unfortunately, running the command in main ef project is not working with the Sub DbContext.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I created an application with the name 'Main' then I added a new Module with the name 'Sub',

    How do you add the module Sub?

    The suite didn't support it, you need to add the Sub module to Main manually.

    We have an example for this: https://github.com/abpframework/abp-samples/tree/master/BookStore-Modular

  • User Avatar
    0
    selwade created

    I added it via abp suite.

    • Select application solution.
    • Navigate to modules.
    • Then create new module.

    This will generate a new module and append it to the solution.

    I am not sure what do you mean by it is not supported via suite.

    Do you mean it is buggy and not working? Cause it is there and I can add the module via it.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Sorry, my bad, after my check, it works for me:

    But strangely no migration is generated for you.

    Can you share the main Main and Sub DbContext code? thanks.

  • User Avatar
    0
    selwade created

    Thank you for your response, I think the issue is here: The "Add migration" option does not exist.

    Anyway as a workaround I just added the migration files to the main ef project manually.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Anyway as a workaround I just added the migration files to the main ef project manually.

    Yes, you need to add the migration file manually

  • User Avatar
    0
    selwade created

    Ok Thank you, but I think adding the migrations as a part of the main EF project will not keep the "Sub" module isolated.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    If you want to keep the sub-module independent, you should use it as a separate application deployment.

    But it will make your project more complex, it used to be a single application, but now it has become a distributed application

    I can show you how to do it if this is what you want.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07