mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-01-03 14:49:59 +01:00
Fix concurrency issues with Blazor Server projects
This commit is contained in:
parent
6532dc4445
commit
c4cc018c77
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ public static class NorthwindContextExtensions
|
|||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="relativePath">Set to override the default of ".."</param>
|
||||
/// <param name="databaseFilename">Set to override the default of "Northwind.db"</param>
|
||||
/// <returns>An IServiceCollection that can be used to add more services.</returns>
|
||||
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<NorthwindContext>(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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ public static class NorthwindContextExtensions
|
|||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="relativePath">Set to override the default of ".."</param>
|
||||
/// <param name="databaseFilename">Set to override the default of "Northwind.db"</param>
|
||||
/// <returns>An IServiceCollection that can be used to add more services.</returns>
|
||||
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<NorthwindContext>(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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue