mirror of https://github.com/abpframework/abp.git
5 changed files with 100 additions and 2 deletions
@ -0,0 +1,16 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<RootNamespace></RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.11" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Volo.Abp.EntityFrameworkCore\Volo.Abp.EntityFrameworkCore.csproj" /> |
||||
|
</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