mirror of https://github.com/abpframework/abp.git
committed by
GitHub
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.PostgreSql</AssemblyName> |
|||
<PackageId>Volo.Abp.EntityFrameworkCore.PostgreSql</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> postgreSqlOptionsAction = null) |
|||
{ |
|||
if (context.ExistingConnection != null) |
|||
{ |
|||
return context.DbContextOptions.UseNpgsql(context.ExistingConnection, postgreSqlOptionsAction); |
|||
} |
|||
else |
|||
{ |
|||
return context.DbContextOptions.UseNpgsql(context.ConnectionString, postgreSqlOptionsAction); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore |
|||
{ |
|||
public static class AbpDbContextOptionsPostgreSqlExtensions |
|||
{ |
|||
public static void UsePostgreSql( |
|||
[NotNull] this AbpDbContextOptions options, |
|||
[CanBeNull] Action<NpgsqlDbContextOptionsBuilder> postgreSqlOptionsAction = null) |
|||
{ |
|||
options.Configure(context => |
|||
{ |
|||
context.UsePostgreSql(postgreSqlOptionsAction); |
|||
}); |
|||
} |
|||
|
|||
public static void UsePostgreSql<TDbContext>( |
|||
[NotNull] this AbpDbContextOptions options, |
|||
[CanBeNull] Action<NpgsqlDbContextOptionsBuilder> postgreSqlOptionsAction = null) |
|||
where TDbContext : AbpDbContext<TDbContext> |
|||
{ |
|||
options.Configure<TDbContext>(context => |
|||
{ |
|||
context.UsePostgreSql(postgreSqlOptionsAction); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -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