Browse Source

Rename MySQL extension methods for clarity

pull/23392/head
maliming 10 months ago
parent
commit
a56ff20c1a
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 10
      docs/en/framework/data/entity-framework-core/mysql.md
  2. 2
      framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextMySQLExtensions.cs
  3. 8
      framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsMySQLExtensions.cs

10
docs/en/framework/data/entity-framework-core/mysql.md

@ -12,15 +12,19 @@ This document explains how to switch to the **MySQL** database provider for **[t
Find ***YourProjectName*EntityFrameworkCoreModule** class inside the `.EntityFrameworkCore` project, remove `typeof(AbpEntityFrameworkCoreSqlServerModule)` from the `DependsOn` attribute, add `typeof(AbpEntityFrameworkCoreMySQLModule)` (also replace `using Volo.Abp.EntityFrameworkCore.SqlServer;` with `using Volo.Abp.EntityFrameworkCore.MySQL;`).
## UseMySQL()
## UsePomeloMySQL()
Find `UseSqlServer()` calls in your solution. Check the following files:
* *YourProjectName*EntityFrameworkCoreModule.cs inside the `.EntityFrameworkCore` project. Replace `UseSqlServer()` with `UseMySQL()`.
* *YourProjectName*DbContextFactory.cs inside the `.EntityFrameworkCore` project. Replace `UseSqlServer()` with `UseMySql()`. Then add a new parameter (`ServerVersion`) to `UseMySql()` method. Example: `.UseMySql(configuration.GetConnectionString("Default"), ServerVersion.Parse("8.0.21-mysql"))`. See [this issue](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/pull/1233) for more information about `ServerVersion`)
* *YourProjectName*EntityFrameworkCoreModule.cs inside the `.EntityFrameworkCore` project. Replace `UseSqlServer()` with `UsePomeloMySQL()`.
* *YourProjectName*DbContextFactory.cs inside the `.EntityFrameworkCore` project. Replace `UseSqlServer()` with `UsePomeloMySQL()`.
> Depending on your solution structure, you may find more code files need to be changed.
## UseMySQLConnector()
You can also use the [MySql.EntityFrameworkCore](https://www.nuget.org/packages/MySql.EntityFrameworkCore) package instead of the Pomelo provider. If you want to use this package, you need to change the `UseMySQLConnector()` method instead of `UsePomeloMySQL()`.
## Change the Connection Strings
MySQL connection strings are different than SQL Server connection strings. So, check all `appsettings.json` files in your solution and replace the connection strings inside them. See the [connectionstrings.com](https://www.connectionstrings.com/mysql) for details of MySQL connection string options.

2
framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextMySQLExtensions.cs

@ -48,7 +48,7 @@ public static class AbpDbContextConfigurationContextMySQLExtensions
/// <summary>
/// This extension method is configuring the use MySql.EntityFrameworkCore as the database provider.
/// </summary>
public static DbContextOptionsBuilder UseMySQL(
public static DbContextOptionsBuilder UseMySQLConnector(
[NotNull] this AbpDbContextConfigurationContext context,
Action<MySql.EntityFrameworkCore.Infrastructure.MySQLDbContextOptionsBuilder>? mySQLOptionsAction = null)
{

8
framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsMySQLExtensions.cs

@ -43,24 +43,24 @@ public static class AbpDbContextOptionsMySQLExtensions
});
}
public static void UseMySQL(
public static void UseMySQLConnector(
[NotNull] this AbpDbContextOptions options,
Action<MySql.EntityFrameworkCore.Infrastructure.MySQLDbContextOptionsBuilder>? mySQLOptionsAction = null)
{
options.Configure(context =>
{
context.UseMySQL(mySQLOptionsAction);
context.UseMySQLConnector(mySQLOptionsAction);
});
}
public static void UseMySQL<TDbContext>(
public static void UseMySQLConnector<TDbContext>(
[NotNull] this AbpDbContextOptions options,
Action<MySql.EntityFrameworkCore.Infrastructure.MySQLDbContextOptionsBuilder>? mySQLOptionsAction = null)
where TDbContext : AbpDbContext<TDbContext>
{
options.Configure<TDbContext>(context =>
{
context.UseMySQL(mySQLOptionsAction);
context.UseMySQLConnector(mySQLOptionsAction);
});
}
}

Loading…
Cancel
Save