首页 > 解决方案 > Bit-Framework 如何在不同项目中拥有模块化 EF 上下文?

问题描述

我在使用位框架的解决方案中有许多项目。当我在不同的项目中使用许多上下文时,我只有最后一个模块的最后一个存储库。

    public IEnumerable<IAppModule> GetAppModules()
    {  
        yield return this;
        yield return new ModuleA();
        yield return new ModuleB();
       ...
    }

    public virtual void ConfigureDependencies(IServiceCollection services,IDependencyManager dependencyManager)
    {
AssemblyContainer.Current.AddAppAssemblies(typeof(ModuleA).GetTypeInfo().Assembly);


AssemblyContainer.Current.AddAppAssemblies(typeof(ModuleB).GetTypeInfo().Assembly);
       ...
       }

在 ModuleA AppModule 中:

dependencyManager.RegisterEfCoreDbContext<ModuleAContext, SqlServerDbContextObjectsProvider>();

在 ModuleB AppModule 中:

dependencyManager.RegisterEfCoreDbContext<ModuleBContext, SqlServerDbContextObjectsProvider>();

标签: c#.netbit-framework

解决方案


推荐阅读