Skip to content

Commit db041b7

Browse files
committed
VCST-1752: Fix performance degradation on SQL Server with OPENJSON
fix: Refactor DB provider setup to use platform Use<T>Database helper
1 parent 965ee86 commit db041b7

File tree

13 files changed

+60
-102
lines changed

13 files changed

+60
-102
lines changed

src/VirtoCommerce.InventoryModule.Data.MySql/DbContextOptionsBuilderExtensions.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace VirtoCommerce.InventoryModule.Data.MySql;
2+
3+
public class MySqlDataAssemblyMarker
4+
{
5+
}

src/VirtoCommerce.InventoryModule.Data.MySql/MySqlDbContextFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public InventoryDbContext CreateDbContext(string[] args)
1616
connectionString,
1717
ResolveServerVersion(serverVersion, connectionString),
1818
db => db
19-
.MigrationsAssembly(typeof(MySqlDbContextFactory).Assembly.GetName().Name));
19+
.MigrationsAssembly(typeof(MySqlDataAssemblyMarker).Assembly.GetName().Name));
2020

2121
return new InventoryDbContext(builder.Options);
2222
}
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1+
# Generate Migrations
12

2-
## Package manager
3-
Add-Migration Initial -Context VirtoCommerce.InventoryModule.Data.Repositories.InventoryDbContext -Verbose -OutputDir Migrations -Project VirtoCommerce.InventoryModule.Data.MySql -StartupProject VirtoCommerce.InventoryModule.Data.MySql -Debug
4-
5-
6-
7-
### Entity Framework Core Commands
8-
```
9-
dotnet tool install --global dotnet-ef --version 6.*
3+
## Install CLI tools for Entity Framework Core
4+
```cmd
5+
dotnet tool install --global dotnet-ef --version 8.0.0
106
```
117

12-
**Generate Migrations**
8+
or update
139

10+
```cmd
11+
dotnet tool update --global dotnet-ef --version 8.0.0
1412
```
15-
dotnet ef migrations add Initial -- "{connection string}"
16-
dotnet ef migrations add Update1 -- "{connection string}"
17-
dotnet ef migrations add Update2 -- "{connection string}"
18-
```
19-
20-
etc..
2113

22-
**Apply Migrations**
14+
## Add Migration
15+
Select Data.<Provider> folder and run following command for each provider:
2316

24-
`dotnet ef database update -- "{connection string}"`
17+
```cmd
18+
dotnet ef migrations add <migration-name>
19+
```

src/VirtoCommerce.InventoryModule.Data.PostgreSql/DbContextOptionsBuilderExtensions.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace VirtoCommerce.InventoryModule.Data.PostgreSql;
2+
3+
public class PostgreSqlDataAssemblyMarker
4+
{
5+
}

src/VirtoCommerce.InventoryModule.Data.PostgreSql/PostgreSqlDbContextFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public InventoryDbContext CreateDbContext(string[] args)
1313

1414
builder.UseNpgsql(
1515
connectionString,
16-
db => db.MigrationsAssembly(typeof(PostgreSqlDbContextFactory).Assembly.GetName().Name));
16+
db => db.MigrationsAssembly(typeof(PostgreSqlDataAssemblyMarker).Assembly.GetName().Name));
1717

1818
return new InventoryDbContext(builder.Options);
1919
}
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1+
# Generate Migrations
12

2-
## Package manager
3-
Add-Migration Initial -Context VirtoCommerce.InventoryModule.Data.Repositories.InventoryDbContext -Verbose -OutputDir Migrations -Project VirtoCommerce.InventoryModule.Data.PostgreSql -StartupProject VirtoCommerce.InventoryModule.Data.PostgreSql -Debug
4-
5-
6-
7-
### Entity Framework Core Commands
8-
```
9-
dotnet tool install --global dotnet-ef --version 6.*
3+
## Install CLI tools for Entity Framework Core
4+
```cmd
5+
dotnet tool install --global dotnet-ef --version 8.0.0
106
```
117

12-
**Generate Migrations**
8+
or update
139

10+
```cmd
11+
dotnet tool update --global dotnet-ef --version 8.0.0
1412
```
15-
dotnet ef migrations add Initial -- "{connection string}"
16-
dotnet ef migrations add Update1 -- "{connection string}"
17-
dotnet ef migrations add Update2 -- "{connection string}"
18-
```
19-
20-
etc..
2113

22-
**Apply Migrations**
14+
## Add Migration
15+
Select Data.<Provider> folder and run following command for each provider:
2316

24-
`dotnet ef database update -- "{connection string}"`
17+
```cmd
18+
dotnet ef migrations add <migration-name>
19+
```

src/VirtoCommerce.InventoryModule.Data.SqlServer/DbContextOptionsBuilderExtensions.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1+
# Generate Migrations
12

2-
## Package manager
3-
Add-Migration Initial -Context VirtoCommerce.InventoryModule.Data.Repositories.InventoryDbContext -Verbose -OutputDir Migrations -Project VirtoCommerce.InventoryModule.Data.SqlServer -StartupProject VirtoCommerce.InventoryModule.Data.SqlServer -Debug
4-
5-
6-
7-
### Entity Framework Core Commands
8-
```
9-
10-
dotnet tool install --global dotnet-ef --version 6.*
3+
## Install CLI tools for Entity Framework Core
4+
```cmd
5+
dotnet tool install --global dotnet-ef --version 8.0.0
116
```
127

13-
**Generate Migrations**
8+
or update
149

15-
```
16-
dotnet ef migrations add Initial -- "{connection string}"
17-
dotnet ef migrations add Update1 -- "{connection string}"
18-
dotnet ef migrations add Update2 -- "{connection string}"
10+
```cmd
11+
dotnet tool update --global dotnet-ef --version 8.0.0
1912
```
2013

21-
etc..
14+
## Add Migration
15+
Select Data.<Provider> folder and run following command for each provider:
2216

23-
**Apply Migrations**
24-
25-
`dotnet ef database update -- "{connection string}"`
17+
```cmd
18+
dotnet ef migrations add <migration-name>
19+
```

0 commit comments

Comments
 (0)