mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
Downgrade Aspire from 13.0.0 to 9.5.2 to support EF Core 8
Co-authored-by: collinbarrett <6483057+collinbarrett@users.noreply.github.com>
This commit is contained in:
parent
99428cf156
commit
f68b8be7bc
3 changed files with 15 additions and 24 deletions
|
|
@ -1,7 +1,6 @@
|
|||
using FilterLists.Directory.Infrastructure.Persistence.Queries;
|
||||
using FilterLists.Directory.Infrastructure.Persistence.Queries.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
|
|
@ -13,25 +12,17 @@ public static class ConfigurationExtensions
|
|||
|
||||
public static void AddInfrastructure(this IHostApplicationBuilder builder)
|
||||
{
|
||||
// Get connection string from configuration
|
||||
var connectionString = builder.Configuration.GetConnectionString("directorydb")
|
||||
?? throw new InvalidOperationException("Connection string 'directorydb' not found.");
|
||||
|
||||
// Register DbContext with standard EF Core configuration
|
||||
builder.Services.AddDbContext<QueryDbContext>(options =>
|
||||
{
|
||||
options.UseSqlServer(connectionString, sqlServerOptions =>
|
||||
{
|
||||
// retry on Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - Undefined error: 0)
|
||||
sqlServerOptions.EnableRetryOnFailure(errorNumbersToAdd: [0]);
|
||||
sqlServerOptions.MigrationsAssembly(MigrationsAssembly);
|
||||
});
|
||||
|
||||
options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
|
||||
options.EnableSensitiveDataLogging(string.Equals(
|
||||
Environment.GetEnvironmentVariable("DOTNET_RUNNING_EF_CORE_TOOLS"), "true",
|
||||
StringComparison.OrdinalIgnoreCase));
|
||||
});
|
||||
// TODO: use different connection strings for migrations and queries (https://stackoverflow.com/q/78564037/2343739)
|
||||
builder.AddSqlServerDbContext<QueryDbContext>("directorydb",
|
||||
_ => { },
|
||||
o => o.UseSqlServer(so =>
|
||||
// retry on Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - Undefined error: 0)
|
||||
so.EnableRetryOnFailure([0])
|
||||
.MigrationsAssembly(MigrationsAssembly))
|
||||
.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
|
||||
.EnableSensitiveDataLogging(string.Equals(
|
||||
Environment.GetEnvironmentVariable("DOTNET_RUNNING_EF_CORE_TOOLS"), "true",
|
||||
StringComparison.OrdinalIgnoreCase)));
|
||||
|
||||
builder.Services.AddHostedService<MigrationService>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.22"/>
|
||||
<PackageReference Include="Aspire.Microsoft.EntityFrameworkCore.SqlServer" Version="9.5.2"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Sdk Name="Aspire.AppHost.Sdk" Version="13.0.0" />
|
||||
<Sdk Name="Aspire.AppHost.Sdk" Version="9.5.2" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
|
|
@ -13,8 +13,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.0.0" />
|
||||
<PackageReference Include="Aspire.Hosting.SqlServer" Version="13.0.0" />
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.5.2" />
|
||||
<PackageReference Include="Aspire.Hosting.SqlServer" Version="9.5.2" />
|
||||
<PackageReference Include="KubernetesClient" Version="18.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue