|
|
|
@ -92,6 +92,8 @@ namespace Volo.Abp.EntityFrameworkCore
|
|
|
|
|
{
|
|
|
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
|
|
|
|
|
|
TrySetDatabaseProvider(modelBuilder);
|
|
|
|
|
|
|
|
|
|
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
|
|
|
|
|
{
|
|
|
|
|
ConfigureBasePropertiesMethodInfo
|
|
|
|
@ -108,6 +110,40 @@ namespace Volo.Abp.EntityFrameworkCore
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void TrySetDatabaseProvider(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
var provider = GetDatabaseProviderOrNull(modelBuilder);
|
|
|
|
|
if (provider != null)
|
|
|
|
|
{
|
|
|
|
|
modelBuilder.SetDatabaseProvider(provider.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual EfCoreDatabaseProvider? GetDatabaseProviderOrNull(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
switch (Database.ProviderName)
|
|
|
|
|
{
|
|
|
|
|
case "Microsoft.EntityFrameworkCore.SqlServer":
|
|
|
|
|
return EfCoreDatabaseProvider.SqlServer;
|
|
|
|
|
case "Npgsql.EntityFrameworkCore.PostgreSQL":
|
|
|
|
|
return EfCoreDatabaseProvider.PostgreSql;
|
|
|
|
|
case "Pomelo.EntityFrameworkCore.MySql":
|
|
|
|
|
return EfCoreDatabaseProvider.MySql;
|
|
|
|
|
case "Devart.Data.Oracle.EFCore":
|
|
|
|
|
return EfCoreDatabaseProvider.Oracle;
|
|
|
|
|
case "Microsoft.EntityFrameworkCore.Sqlite":
|
|
|
|
|
return EfCoreDatabaseProvider.Sqlite;
|
|
|
|
|
case "Microsoft.EntityFrameworkCore.InMemory":
|
|
|
|
|
return EfCoreDatabaseProvider.InMemory;
|
|
|
|
|
case "FirebirdSql.EntityFrameworkCore.Firebird":
|
|
|
|
|
return EfCoreDatabaseProvider.Firebird;
|
|
|
|
|
case "Microsoft.EntityFrameworkCore.Cosmos":
|
|
|
|
|
return EfCoreDatabaseProvider.Cosmos;
|
|
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override async Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|