Open Closed

Add application module to my existing monolithic application #1129


User avatar
0
jhsanc created

Hello, I need a guide to develop an blazor ui application module, and how I can add this module to my existing monolithic blazor application. I need also know how I can do relations between my principal monolithic application entities to my blazor ui module in other solution. I already read the documents of modules, and plugins but I need more details, and if you have an getting started of this was great.

Thank you,

Johan

  • ABP Commertial Team version: v4.3.0-rc.1
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:

6 Answer(s)
  • User Avatar
    1
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Using blazor UI module is no different from web UI module. You just need to add module dependencies to the application.

    example:

    [DependsOn(typeof(BlazorModuleUIModule))] 
    public class BlazorAppModule
    
    [DependsOn(typeof(BlazoApplicationModule))] 
    public class BlazorApplicationModule
    
    [DependsOn(typeof(BlazoDomainModule))] 
    public class BlazorDomainModule
    

    etc..

  • User Avatar
    1
    jhsanc created

    Sorry this not it's a solution from question. I'm going to reformulate my question: For instance for BookStore-Modular: https://github.com/abpframework/abp-samples/tree/master/BookStore-Modular for example. How is the most efficient way to "share" part of "whole database schema" across multiple modules (so that some tables are not defined on application-level but only on module level)?

    If application would have the same architecture as BookStore-Modular and part od database would be using the same tables in 4 modules (and other parts of the application - modules don't use these tables at all).

    Maybe module, which "holds" tables for modules and each module that should use these tables should reference this "database module"?

    I need a shared module which defines the shared entities

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Usually we should not use the entity of another module in a module, it will blur the boundaries of your module.

    A good module should focus on its own entities, but sometimes the module needs to read the data of another module. We have the following way:

    • Use domain events https://docs.abp.io/en/abp/latest/Distributed-Event-Bus
    • Use dynamic HTTI API proxy (reference .HttpApi.Client module) https://docs.abp.io/en/abp/latest/API/Dynamic-CSharp-API-Clients
    • Use repository(reference .domain module), In this way, you can read the database directly.

    If you really need to share entities between modules, you can define a Entity.Shared project and other modules reference this project. that's ok.

  • User Avatar
    0
    jhsanc created

    Hi,

    Usually we should not use the entity of another module in a module, it will blur the boundaries of your module.

    A good module should focus on its own entities, but sometimes the module needs to read the data of another module. We have the following way:

    • Use domain events https://docs.abp.io/en/abp/latest/Distributed-Event-Bus
    • Use dynamic HTTI API proxy (reference .HttpApi.Client module) https://docs.abp.io/en/abp/latest/API/Dynamic-CSharp-API-Clients
    • Use repository(reference .domain module), In this way, you can read the database directly.

    If you really need to share entities between modules, you can define a Entity.Shared project and other modules reference this project. that's ok.

    Can you explain me more this "Use repository(reference .domain module), In this way, you can read the database directly". Only add the reference of the project to the project app.

    In the generated code of abp framework in DbContext say this: * It does not include entities of the used modules, because each module has already * its own DbContext class. If you want to share some database tables with the used modules, * just create a structure like done for AppUser. * * Don't use this DbContext for database migrations since it does not contain tables of the * used modules (as explained above). See SportsMigrationsDbContext for migrations. But I need know if this is a good practice.

    Thank you,

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I make an example for you: https://github.com/realLiangshiwei/Qa1129.

    Qa module and identity module are two databases

      "ConnectionStrings": {
        "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=Qa_Main;Trusted_Connection=True",
        "Qa": "Server=(LocalDb)\\MSSQLLocalDB;Database=Qa_Module;Trusted_Connection=True"
      }
    

  • User Avatar
    0
    jhsanc created

    Hi,

    I make an example for you: https://github.com/realLiangshiwei/Qa1129.

    Qa module and identity module are two databases

      "ConnectionStrings": { 
        "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=Qa_Main;Trusted_Connection=True", 
        "Qa": "Server=(LocalDb)\\MSSQLLocalDB;Database=Qa_Module;Trusted_Connection=True" 
      } 
    

    This example it's great, thank you so much.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11