如何在位框架的不同项目中使用模块化EF上下文?

时间:2018-06-25 13:30:31

标签: c# .net bit-framework

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

    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>();

0 个答案:

没有答案
相关问题