-
Notifications
You must be signed in to change notification settings - Fork 844
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VCST-1752: Fix performance degradation on SQL Server (#2834)
- Loading branch information
1 parent
c3adf25
commit e5df65b
Showing
15 changed files
with
121 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
src/VirtoCommerce.Platform.Data.MySql/DbContextOptionsBuilderExtensions.cs
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
src/VirtoCommerce.Platform.Data.MySql/Extensions/DbContextOptionsBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace VirtoCommerce.Platform.Data.MySql.Extensions; | ||
|
||
public static class DbContextOptionsBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Configures the context to use MySql. | ||
/// </summary> | ||
public static DbContextOptionsBuilder UseMySqlDatabase( | ||
this DbContextOptionsBuilder optionsBuilder, | ||
string? connectionString, | ||
Type migrationsAssemblyMarkerType, | ||
IConfiguration configuration, | ||
Action<MySqlDbContextOptionsBuilder, IConfiguration>? mySqlOptionsAction = null) | ||
{ | ||
return optionsBuilder.UseMySql(connectionString, | ||
ServerVersion.AutoDetect(connectionString), | ||
mySqlDbContextOptionsBuilder => | ||
{ | ||
mySqlDbContextOptionsBuilder.MigrationsAssembly(migrationsAssemblyMarkerType.Assembly.GetName().Name); | ||
mySqlOptionsAction?.Invoke(mySqlDbContextOptionsBuilder, configuration); | ||
}); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/VirtoCommerce.Platform.Data.MySql/MySqlDataAssemblyMarker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace VirtoCommerce.Platform.Data.MySql; | ||
|
||
public class MySqlDataAssemblyMarker | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
src/VirtoCommerce.Platform.Data.PostgreSql/DbContextOptionsBuilderExtensions.cs
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/VirtoCommerce.Platform.Data.PostgreSql/Extensions/DbContextOptionsBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Configuration; | ||
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure; | ||
|
||
namespace VirtoCommerce.Platform.Data.PostgreSql.Extensions; | ||
|
||
public static class DbContextOptionsBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Configures the context to use PostgreSql. | ||
/// </summary> | ||
public static DbContextOptionsBuilder UsePostgreSqlDatabase( | ||
this DbContextOptionsBuilder optionsBuilder, | ||
string? connectionString, | ||
Type migrationsAssemblyMarkerType, | ||
IConfiguration configuration, | ||
Action<NpgsqlDbContextOptionsBuilder, IConfiguration>? npgsqlOptionsAction = null) | ||
{ | ||
return optionsBuilder.UseNpgsql(connectionString, | ||
npgsqlDbContextOptionsBuilder => | ||
{ | ||
npgsqlDbContextOptionsBuilder.MigrationsAssembly(migrationsAssemblyMarkerType.Assembly.GetName().Name); | ||
npgsqlOptionsAction?.Invoke(npgsqlDbContextOptionsBuilder, configuration); | ||
}); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/VirtoCommerce.Platform.Data.PostgreSql/PostgreSqlDataAssemblyMarker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace VirtoCommerce.Platform.Data.PostgreSql; | ||
|
||
public class PostgreSqlDataAssemblyMarker | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
src/VirtoCommerce.Platform.Data.SqlServer/DbContextOptionsBuilderExtensions.cs
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
src/VirtoCommerce.Platform.Data.SqlServer/Extensions/DbContextOptionsBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace VirtoCommerce.Platform.Data.SqlServer.Extensions; | ||
|
||
public static class DbContextOptionsBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Configures the context to use SqlServer. | ||
/// </summary> | ||
public static DbContextOptionsBuilder UseSqlServerDatabase( | ||
this DbContextOptionsBuilder optionsBuilder, | ||
string? connectionString, | ||
Type migrationsAssemblyMarkerType, | ||
IConfiguration configuration, | ||
Action<SqlServerDbContextOptionsBuilder, IConfiguration>? sqlServerOptionsAction = null) | ||
{ | ||
return optionsBuilder.UseSqlServer(connectionString, | ||
sqlServerOptionsBuilder => | ||
{ | ||
var compatibilityLevel = configuration.GetValue<int?>("SqlServer:CompatibilityLevel", null); | ||
if (compatibilityLevel != null) | ||
{ | ||
sqlServerOptionsBuilder.UseCompatibilityLevel(compatibilityLevel.Value); | ||
} | ||
sqlServerOptionsBuilder.MigrationsAssembly(migrationsAssemblyMarkerType.Assembly.GetName().Name); | ||
sqlServerOptionsAction?.Invoke(sqlServerOptionsBuilder, configuration); | ||
}); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/VirtoCommerce.Platform.Data.SqlServer/SqlServerDataAssemblyMarker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace VirtoCommerce.Platform.Data.SqlServer; | ||
|
||
public class SqlServerDataAssemblyMarker | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters