Search code examples
asp.net-corearchitectureentity-framework-coreentity-framework-migrationsaspnetboilerplate

ASP.NET Boilerplate project structure for new entities/services


I have started to play around with ASP.NET Boilerplate framework. I want to keep my application-specific entities and services in two separate projects. This will keep the core framework project untouched.

However I am not sure if i have the entities in a separate project how will the migrations work. The module system in the documentation touches about the logic piece, but it does not talk about entities that are local to the module (so each module has its own entity that gets created when migrations take place).

What options do we have if we need to separate our entities and services to individual projects?


Solution

  • However I am not sure if i have the entities in a separate project how will the migrations work.

    Migrations work based on the DbSet that you define for each entity in DbContext.

    What options do we have if we need to separate our entities and services to individual projects?

    So you can have the entities in a separate project.

    1. Add a dependency on YourSeparateCoreModule to *EntityFrameworkModule:

      [DependsOn(
          typeof(AbpProjectNameCoreModule), 
          typeof(YourSeparateCoreModule), // Add this
          typeof(AbpZeroCoreEntityFrameworkCoreModule))]
      public class AbpProjectNameEntityFrameworkModule : AbpModule
      
    2. Then add a DbSet for each of the entities.