Data isolation for Modular Monoliths - DB Schemas, EF Core

Поділитися
Вставка
  • Опубліковано 30 чер 2024
  • ☄️ Master the Modular Monolith Architecture: bit.ly/3SXlzSt
    📌 Accelerate your Clean Architecture skills: bit.ly/3PupkOJ
    🚀 Support me on Patreon to access the source code: / milanjovanovic
    A modular monolith is an architectural pattern that structures the application into independent modules or components with well-defined boundaries. The modules are split based on logical boundaries, grouping together related functionalities. This approach significantly improves the cohesion of the system.
    In this video, I'll explain why data isolation between modules is important and explore how we can implement logical data isolation using schemas.
    What Is a Modular Monolith?
    www.milanjovanovic.tech/blog/...
    Monolith to Microservices: How a Modular Monolith Helps
    www.milanjovanovic.tech/blog/...
    Modular Monolith Communication Patterns
    www.milanjovanovic.tech/blog/...
    Modular Monolith Data Isolation
    www.milanjovanovic.tech/blog/...
    Join my weekly .NET newsletter:
    www.milanjovanovic.tech
    Read my Blog here:
    www.milanjovanovic.tech/blog
    Chapters
    0:00 Modular Monolith data isolation
    2:16 Adding database Schemas with EF Core
    6:46 Fixing the SQL queries
    8:45 Creating EF Core SQL migration scripts
    9:59 Adding EF migration history to the schema
    11:24 Fixing the Outbox processor
    14:46 Enforcing data isolation?
  • Наука та технологія

КОМЕНТАРІ • 27

  • @MilanJovanovicTech
    @MilanJovanovicTech  Місяць тому +1

    𝗣.𝗦. If you liked this, you will love The .NET Weekly newsletter. Join 49,000+ engineers here → bit.ly/3Qx7Cu5

  • @sweeperq
    @sweeperq Місяць тому +11

    Why go through the trouble of making the schema a constant for the migration, only to hard-code it in all the queries?

    • @MilanJovanovicTech
      @MilanJovanovicTech  Місяць тому

      Meh, just wanted to make things explicit for the raw SQL example. All it takes is move the constant one level below, and reuse it.

  • @mesutdemirci7933
    @mesutdemirci7933 Місяць тому

    Great video ..thanks a lot

  • @alexdefaro
    @alexdefaro 26 днів тому +1

    Hi Milan... Great video... Would you use the same approach if you have different databases for each module?

    • @MilanJovanovicTech
      @MilanJovanovicTech  26 днів тому

      Different SQL database? Using schemas could still make sense.

  • @Nikegamecentral
    @Nikegamecentral Місяць тому +1

    Hello Milan! Thank you very much for your videos! Are you familiar with the actor model of programming? For example, about an application written using Akka? Can you release a video about this? It would be very interesting

  • @artemissterio
    @artemissterio Місяць тому

    Great video 👍
    But I still wonder - is there any other option for outbox messages table instead of code duplication?

    • @MilanJovanovicTech
      @MilanJovanovicTech  Місяць тому

      Expanding the abstraction, and passing in the respective schema

    • @artemissterio
      @artemissterio Місяць тому +1

      @@MilanJovanovicTech How about using only one OutboxMessages table (in public schema, for example) with only one processor?

    • @dariuszlenartowicz
      @dariuszlenartowicz Місяць тому

      @@artemissterio it's ok too - depends on how modules are busy :)

  • @nagibatorbatcka86
    @nagibatorbatcka86 Місяць тому

    Great video.
    How about creating video about prometheus or loki ? Can be in combination with Grafana for better data visualization.

  • @nicholasgueli305
    @nicholasgueli305 Місяць тому

    great video.
    wouldn't it be better to have one module that handles all the outbox messages? if I have N modules I have N background jobs if performance might decrease.

    • @MilanJovanovicTech
      @MilanJovanovicTech  Місяць тому +1

      That would introduce coupling, though. Depends on what you want. Also, having one outbox processor would decrease the overall throughput.

  • @LCMinato
    @LCMinato Місяць тому

    Hi Milan, thanks a lot as always for your videos, love them !
    I'm interested by your course about the MMA, and I was wondering if you'd consider uploading it on platforms like Udemy ?
    thanks for helping

  • @StjepanPuljko
    @StjepanPuljko Місяць тому

    I don't know if I'm missing something, but you are using Hangfire for further processing outbox messages? If that is so, Hangfire should already have it's own schema or database, so why don't you just write common integrations service to process outbox messages, since if you are using Hangfire (which is external service) it can't be domain event.

    • @MilanJovanovicTech
      @MilanJovanovicTech  Місяць тому

      Hangfire/Quartz/Hosted service, it's an implementation detail mostly

  • @SajjadKhan-BSK
    @SajjadKhan-BSK 14 днів тому

    If we have seperate databases per Module then incase while querying we gonna needs to fetch data from a table which is inside anotherr database ??

    • @MilanJovanovicTech
      @MilanJovanovicTech  14 днів тому

      Try not to mix queries from different modules

    • @SajjadKhan-BSK
      @SajjadKhan-BSK 14 днів тому

      @@MilanJovanovicTech
      Ok
      Let take one example here milan
      I have modules like
      Patient Demographics
      Appointments
      Reports
      In such case, I can make above modules as SubModules under Module Reception .
      By this, I can have all related tables under one Module.
      Is that correct ?

  • @Kasiux
    @Kasiux Місяць тому

    Arent modular monoliths just monoliths but with good system design?

    • @MilanJovanovicTech
      @MilanJovanovicTech  Місяць тому

      Kind of: www.milanjovanovic.tech/blog/what-is-a-modular-monolith