新建Abpvnext 5.0版本的项目后发现 数据库处理的项目由原先的两个合并为一个~.EntityFrameworkCore,而AbpVnext 官方更新暂时没有更新Volo.Abp.EntityFrameworkCore.Oracle,只能支持到Volo.Abp [4.0,5.0)版本.
解决方案:
1.删除~.EntityFrameworkCore内的包,只留下 Microsoft.EntityFrameworkCore.Tools
2.引入包 注意查看包依赖
Oracle.EntityFrameworkCore,
Oracle.ManagedDataAccess.Core,
Volo.Abp.AuditLogging.EntityFrameworkCore
3.修改 ~DbContextFactory.cs 内 CreateDbContext 函数内的 Use~(database type) 为 UseOracle
4.修改 ~EntityFrameworkCoreModule.cs 内ConfigureServices 为下方代码:
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<SmcspDbContext>(options =>
{
/* Remove "includeAllEntities: true" to create
* default repositories only for aggregate roots */
options.AddDefaultRepositories(includeAllEntities: true);
});
Configure<AbpDbContextOptions>(options =>
{
/* The main point to change your DBMS.
* See also SmcspMigrationsDbContextFactory for EF Core tooling. */
options.Configure(new Action<AbpDbContextConfigurationContext>(context =>
{
if (context.ExistingConnection != null)
{
context.DbContextOptions.UseOracle(context.ExistingConnection, new Action<OracleDbContextOptionsBuilder>(optionsBuilder => {
optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery);
optionsBuilder.UseOracleSQLCompatibility("11");
}));
}
context.DbContextOptions.UseOracle(context.ConnectionString, new Action<OracleDbContextOptionsBuilder>(optionsBuilder => {
optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery);
optionsBuilder.UseOracleSQLCompatibility("11");
}));
}));
});
}
至此 Oracle 适配完毕。
按照此方法也可修改适配其他版本的Abp 或 AbpVnext框架。