Browse Source
Merge pull request #11284 from abpframework/EnableLegacyTimestampBehavior
Move `EnableLegacyTimestampBehavior` to `AbpDbContext`.
pull/11288/head
liangshiwei
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
7 additions and
8 deletions
-
framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo/Abp/EntityFrameworkCore/PostgreSql/AbpEntityFrameworkCorePostgreSqlModule.cs
-
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
|
|
|
@ -1,5 +1,4 @@ |
|
|
|
using System; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Volo.Abp.EntityFrameworkCore.DistributedEvents; |
|
|
|
using Volo.Abp.Guids; |
|
|
|
using Volo.Abp.Modularity; |
|
|
|
@ -11,12 +10,6 @@ namespace Volo.Abp.EntityFrameworkCore.PostgreSql; |
|
|
|
)] |
|
|
|
public class AbpEntityFrameworkCorePostgreSqlModule : AbpModule |
|
|
|
{ |
|
|
|
public override void PreConfigureServices(ServiceConfigurationContext context) |
|
|
|
{ |
|
|
|
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
|
|
|
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); |
|
|
|
} |
|
|
|
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context) |
|
|
|
{ |
|
|
|
Configure<AbpSequentialGuidGeneratorOptions>(options => |
|
|
|
|
|
|
|
@ -122,6 +122,12 @@ public abstract class AbpDbContext<TDbContext> : DbContext, IAbpEfCoreDbContext, |
|
|
|
if (provider != null) |
|
|
|
{ |
|
|
|
modelBuilder.SetDatabaseProvider(provider.Value); |
|
|
|
|
|
|
|
if (provider.Value == EfCoreDatabaseProvider.PostgreSql) |
|
|
|
{ |
|
|
|
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
|
|
|
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|