c# - 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>();
解决方案
推荐阅读
- python - 从熊猫数据框中选择多个值
- postgresql - Postgres 使用 2d golang 切片选择 WHERE col1, col2 IN
- typescript - 如何使用 TypeScript 显示当天的工作日名称
- microsoft-graph-api - Microsoft Graph API 更新架构扩展
- python-3.x - Python Pandas:无法使用 df.loc 分配列表值
- sql - 运行后取消主触发器(更新后)触发器类型
- html - 将 html 属性重构为 html5 的工具
- python-3.x - 捕获 SSL 预主密钥 - Python Youtube-DL
- postgresql - 为什么交叉表查询返回多行而不是一行?
- javascript - 无法通过其默认构造函数动态实例化我的自定义元素