OceanBase.Abp.EntityFrameworkCore is an ABP Provider for ABP + EF Core + OceanBase Oracle mode, replacing the Volo.Abp.EntityFrameworkCore.Oracle connection path. The application must also reference the OceanBase.EntityFrameworkCore6/7/8 EF Core Provider and the OceanBase.ManagedDataAccess driver that match the major version.
For the connection string format, see Connection strings; for the capabilities of the EF Core Provider, see Use Entity Framework Core.
Note
The ABP Provider supports application target frameworks net6.0, net7.0, and net8.0, which must match the main versions of the application's ABP and EF Core. The V1.3.1 validation matrix is ABP 6.0.3 / 7.0.0 / 8.3.4 paired with EF Core 6 / 7 / 8 Providers.
Installation
Reference the corresponding NuGet package for the application's target framework (example: EF Core 8 + ABP 8):
dotnet add package OceanBase.ManagedDataAccess
dotnet add package OceanBase.EntityFrameworkCore8
dotnet add package OceanBase.Abp.EntityFrameworkCore
Simultaneously install the ABP module packages required by the business (such as Identity, TenantManagement, OpenIddict, etc.), with versions matching the major version of Volo.Abp.EntityFrameworkCore that OceanBase.Abp.EntityFrameworkCore depends on.
Application target framework |
EF Core Provider |
Typical ABP Versions |
|---|---|---|
net6.0 |
OceanBase.EntityFrameworkCore6 |
ABP 6.x |
net7.0 |
OceanBase.EntityFrameworkCore7 |
ABP 7.x |
net8.0 |
OceanBase.EntityFrameworkCore8 |
ABP 8.x |
Module registration
In the EntityFrameworkCore Layer Module:
- Replace
AbpEntityFrameworkCoreOracleModule(if present) inDependsOnwithAbpEntityFrameworkCoreOceanBaseModule. - In
ConfigureServices, configure all (or specified)AbpDbContextinstances withAbpDbContextOptions.UseOceanBaseForOracle().
using Microsoft.Extensions.DependencyInjection;
using OceanBase.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity;
[DependsOn(
typeof(AbpEntityFrameworkCoreOceanBaseModule),
typeof(AbpIdentityEntityFrameworkCoreModule)
// … Other ABP EF modules
)]
public class MyProjectEntityFrameworkCoreModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<MyProjectDbContext>(options =>
{
options.AddDefaultRepositories(includeAllEntities: true);
});
Configure<AbpDbContextOptions>(options =>
{
// Use OceanBase Oracle for all AbpDbContext instances
options.UseOceanBaseForOracle();
// Or configure it only for the specified DbContext:
// options.UseOceanBaseForOracle<MyProjectDbContext>();
});
}
}
The UseOceanBaseForOracle extension is located in the namespace OceanBase.Abp.EntityFrameworkCore. Its signature is consistent with the UseOracle() method of the official ABP Oracle module, allowing for a direct migration using the original Oracle template.
DbContext and connection string
The definition of AbpDbContext, the mapping in the Configure* module, and [ConnectionStringName] are the same as in a standard ABP project. The connection string is written in appsettings.json:
{
"ConnectionStrings": {
"Default": "server=<host>;port=2881;user id=<account>;password=<password>;database=<schema>;"
}
}
In multi-tenant database sharding scenarios, you can additionally configure tenant-specific connection strings (such as TenantDefault), which are parsed by the ABP tenant and used with DbMigrator.
Database migration
The migration process is consistent with the official ABP documentation:
# In the directory of the EntityFrameworkCore project
dotnet ef migrations add Initial
# In the DbMigrator project
dotnet run
The design-time factory (IDesignTimeDbContextFactory) also uses UseOceanBaseForOracle() to configure DbContextOptions.
Extended capabilities provided by the ABP Provider
Compared to "only referencing the EF Core Provider and integrating ABP manually," this ABP Provider additionally includes:
capability |
Description |
|---|---|
| Module registration | AbpEntityFrameworkCoreOceanBaseModuleRegister default options for OceanBase (such as sequential GUID type). |
| Generate Global Filter SQL | Adapted filter translations for ABP multi-tenancy and soft deletion in Oracle-compatible mode |
ExtraPropertiesValue conversion |
Compatible with Oracle's extended attribute JSON/numeric precision |
| DbContext Configuration | UseOceanBaseForOracle()Integrate with the ABP DbContext configuration process |
Considerations
1. Do not manually set UseDbFunction (ABP 8 + EF Core 8)
The ABP Provider defaults to UseDbFunction = false. If manually changed to true, EFCompileAsyncQuery may fix the filter switch state at compile time, thereby bypassing ABP's multi-tenant/soft-deletion global filters. If your application uses Compiled Queries, please keep the default configuration.
2. Replacement relationship with the official Oracle module
- NuGet package: Replace
Volo.Abp.EntityFrameworkCore.OraclewithOceanBase.Abp.EntityFrameworkCore. - Module: Replace
AbpEntityFrameworkCoreOracleModulewithAbpEntityFrameworkCoreOceanBaseModule. - DbContext configuration: Replace
options.UseOracle()withoptions.UseOceanBaseForOracle().
3. Version and capability boundaries
- You must use the EF Core 6/7/8 Provider and driver that matches the main version of the ABP Provider; do not mix assemblies.
- EF migration scripts for ABP modules (such as Identity, OpenIddict, etc.) must be tested in the target OceanBase Oracle database.
- For more information on EF capability boundaries (LINQ translation, reverse engineering, type mapping), see Use Entity Framework Core.
Reference example
The driver repository provides a sample project for ABP 8.3.4 + EF Core 8, samples/AbpOceanBase (including DbMigrator, HttpApi.Host, OpenIddict), which can serve as a reference skeleton for migration from Volo.Abp.EntityFrameworkCore.Oracle.
