mirror of https://github.com/abpframework/abp.git
5 changed files with 98 additions and 0 deletions
@ -0,0 +1,24 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<AssemblyName>Volo.Abp.EntityFrameworkCore.SqlServer</AssemblyName> |
||||
|
<PackageId>Volo.Abp.EntityFrameworkCore.SqlServer</PackageId> |
||||
|
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
||||
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
||||
|
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
||||
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Volo.Abp.EntityFrameworkCore\Volo.Abp.EntityFrameworkCore.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.2" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,25 @@ |
|||||
|
using System; |
||||
|
using JetBrains.Annotations; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure; |
||||
|
using Volo.Abp.EntityFrameworkCore.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.EntityFrameworkCore |
||||
|
{ |
||||
|
public static class AbpDbContextConfigurationContextPostgreSqlExtensions |
||||
|
{ |
||||
|
public static DbContextOptionsBuilder UsePostgreSql( |
||||
|
[NotNull] this AbpDbContextConfigurationContext context, |
||||
|
[CanBeNull] Action<NpgsqlDbContextOptionsBuilder> sqlServerOptionsAction = null) |
||||
|
{ |
||||
|
if (context.ExistingConnection != null) |
||||
|
{ |
||||
|
return context.DbContextOptions.UseNpgsql(context.ExistingConnection, sqlServerOptionsAction); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return context.DbContextOptions.UseNpgsql(context.ConnectionString, sqlServerOptionsAction); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
using System; |
||||
|
using JetBrains.Annotations; |
||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure; |
||||
|
|
||||
|
namespace Volo.Abp.EntityFrameworkCore |
||||
|
{ |
||||
|
public static class AbpDbContextOptionsSqlServerExtensions |
||||
|
{ |
||||
|
public static void UsePostgreSql( |
||||
|
[NotNull] this AbpDbContextOptions options, |
||||
|
[CanBeNull] Action<NpgsqlDbContextOptionsBuilder> sqlServerOptionsAction = null) |
||||
|
{ |
||||
|
options.Configure(context => |
||||
|
{ |
||||
|
context.UsePostgreSql(sqlServerOptionsAction); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public static void UsePostgreSql<TDbContext>( |
||||
|
[NotNull] this AbpDbContextOptions options, |
||||
|
[CanBeNull] Action<NpgsqlDbContextOptionsBuilder> sqlServerOptionsAction = null) |
||||
|
where TDbContext : AbpDbContext<TDbContext> |
||||
|
{ |
||||
|
options.Configure<TDbContext>(context => |
||||
|
{ |
||||
|
context.UsePostgreSql(sqlServerOptionsAction); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp.EntityFrameworkCore.PostgreSql |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(AbpEntityFrameworkCoreModule) |
||||
|
)] |
||||
|
public class AbpEntityFrameworkCorePostgreSqlModule : AbpModule |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue