diff --git a/vs4win/PracticalApps/Northwind.Common.DataContext.SqlServer/NorthwindContextExtensions.cs b/vs4win/PracticalApps/Northwind.Common.DataContext.SqlServer/NorthwindContextExtensions.cs
index 5ac14ff..f91c486 100644
--- a/vs4win/PracticalApps/Northwind.Common.DataContext.SqlServer/NorthwindContextExtensions.cs
+++ b/vs4win/PracticalApps/Northwind.Common.DataContext.SqlServer/NorthwindContextExtensions.cs
@@ -23,7 +23,9 @@ public static class NorthwindContextExtensions
options.LogTo(WriteLine, // Console
new[] { Microsoft.EntityFrameworkCore
.Diagnostics.RelationalEventId.CommandExecuting });
- });
+ },
+ // Register with a transient lifetime to avoid concurrency issues with Blazor Server projects.
+ contextLifetime: ServiceLifetime.Transient, optionsLifetime: ServiceLifetime.Transient);
return services;
}
diff --git a/vs4win/PracticalApps/Northwind.Common.DataContext.Sqlite/NorthwindContextExtensions.cs b/vs4win/PracticalApps/Northwind.Common.DataContext.Sqlite/NorthwindContextExtensions.cs
index ceb676d..8f98ab2 100644
--- a/vs4win/PracticalApps/Northwind.Common.DataContext.Sqlite/NorthwindContextExtensions.cs
+++ b/vs4win/PracticalApps/Northwind.Common.DataContext.Sqlite/NorthwindContextExtensions.cs
@@ -10,11 +10,13 @@ public static class NorthwindContextExtensions
///
///
/// Set to override the default of ".."
+ /// Set to override the default of "Northwind.db"
/// An IServiceCollection that can be used to add more services.
public static IServiceCollection AddNorthwindContext(
- this IServiceCollection services, string relativePath = "..")
+ this IServiceCollection services, string relativePath = "..",
+ string databaseFilename = "Northwind.db")
{
- string databasePath = Path.Combine(relativePath, "Northwind.db");
+ string databasePath = Path.Combine(relativePath, databaseFilename);
services.AddDbContext(options =>
{
@@ -23,7 +25,9 @@ public static class NorthwindContextExtensions
options.LogTo(WriteLine, // Console
new[] { Microsoft.EntityFrameworkCore
.Diagnostics.RelationalEventId.CommandExecuting });
- });
+ },
+ // Register with a transient lifetime to avoid concurrency issues with Blazor Server projects.
+ contextLifetime: ServiceLifetime.Transient, optionsLifetime: ServiceLifetime.Transient);
return services;
}
diff --git a/vscode/PracticalApps/Northwind.Common.DataContext.SqlServer/NorthwindContextExtensions.cs b/vscode/PracticalApps/Northwind.Common.DataContext.SqlServer/NorthwindContextExtensions.cs
index 5ac14ff..f91c486 100644
--- a/vscode/PracticalApps/Northwind.Common.DataContext.SqlServer/NorthwindContextExtensions.cs
+++ b/vscode/PracticalApps/Northwind.Common.DataContext.SqlServer/NorthwindContextExtensions.cs
@@ -23,7 +23,9 @@ public static class NorthwindContextExtensions
options.LogTo(WriteLine, // Console
new[] { Microsoft.EntityFrameworkCore
.Diagnostics.RelationalEventId.CommandExecuting });
- });
+ },
+ // Register with a transient lifetime to avoid concurrency issues with Blazor Server projects.
+ contextLifetime: ServiceLifetime.Transient, optionsLifetime: ServiceLifetime.Transient);
return services;
}
diff --git a/vscode/PracticalApps/Northwind.Common.DataContext.Sqlite/NorthwindContextExtensions.cs b/vscode/PracticalApps/Northwind.Common.DataContext.Sqlite/NorthwindContextExtensions.cs
index ceb676d..8f98ab2 100644
--- a/vscode/PracticalApps/Northwind.Common.DataContext.Sqlite/NorthwindContextExtensions.cs
+++ b/vscode/PracticalApps/Northwind.Common.DataContext.Sqlite/NorthwindContextExtensions.cs
@@ -10,11 +10,13 @@ public static class NorthwindContextExtensions
///
///
/// Set to override the default of ".."
+ /// Set to override the default of "Northwind.db"
/// An IServiceCollection that can be used to add more services.
public static IServiceCollection AddNorthwindContext(
- this IServiceCollection services, string relativePath = "..")
+ this IServiceCollection services, string relativePath = "..",
+ string databaseFilename = "Northwind.db")
{
- string databasePath = Path.Combine(relativePath, "Northwind.db");
+ string databasePath = Path.Combine(relativePath, databaseFilename);
services.AddDbContext(options =>
{
@@ -23,7 +25,9 @@ public static class NorthwindContextExtensions
options.LogTo(WriteLine, // Console
new[] { Microsoft.EntityFrameworkCore
.Diagnostics.RelationalEventId.CommandExecuting });
- });
+ },
+ // Register with a transient lifetime to avoid concurrency issues with Blazor Server projects.
+ contextLifetime: ServiceLifetime.Transient, optionsLifetime: ServiceLifetime.Transient);
return services;
}