mirror of https://github.com/abpframework/abp.git
committed by
GitHub
5 changed files with 108 additions and 2 deletions
@ -0,0 +1,24 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<AssemblyName>Volo.Abp.EntityFrameworkCore.MySQL</AssemblyName> |
|||
<PackageId>Volo.Abp.EntityFrameworkCore.MySQL</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="MySql.Data.EntityFrameworkCore" Version="8.0.11" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,27 @@ |
|||
using JetBrains.Annotations; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using MySql.Data.EntityFrameworkCore.Infraestructure; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Volo.Abp.EntityFrameworkCore.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore |
|||
{ |
|||
public static class AbpDbContextConfigurationContextMySQLExtensions |
|||
{ |
|||
public static DbContextOptionsBuilder UseMySQL( |
|||
[NotNull] this AbpDbContextConfigurationContext context, |
|||
[CanBeNull] Action<MySQLDbContextOptionsBuilder> mySQLOptionsAction = null) |
|||
{ |
|||
if (context.ExistingConnection != null) |
|||
{ |
|||
return context.DbContextOptions.UseMySQL(context.ExistingConnection, mySQLOptionsAction); |
|||
} |
|||
else |
|||
{ |
|||
return context.DbContextOptions.UseMySQL(context.ConnectionString, mySQLOptionsAction); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using JetBrains.Annotations; |
|||
using MySql.Data.EntityFrameworkCore.Infraestructure; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore |
|||
{ |
|||
public static class AbpDbContextOptionsMySQLExtensions |
|||
{ |
|||
public static void UseMySQL( |
|||
[NotNull] this AbpDbContextOptions options, |
|||
[CanBeNull] Action<MySQLDbContextOptionsBuilder> mySQLOptionsAction = null) |
|||
{ |
|||
options.Configure(context => |
|||
{ |
|||
context.UseMySQL(mySQLOptionsAction); |
|||
}); |
|||
} |
|||
|
|||
public static void UseMySQL<TDbContext>( |
|||
[NotNull] this AbpDbContextOptions options, |
|||
[CanBeNull] Action<MySQLDbContextOptionsBuilder> mySQLOptionsAction = null) |
|||
where TDbContext : AbpDbContext<TDbContext> |
|||
{ |
|||
options.Configure<TDbContext>(context => |
|||
{ |
|||
context.UseMySQL(mySQLOptionsAction); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.MySQL |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpEntityFrameworkCoreModule) |
|||
)] |
|||
public class AbpEntityFrameworkCoreMySQLModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddAssemblyOf<AbpEntityFrameworkCoreMySQLModule>(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue