Skip to content

Commit

Permalink
add AppContext.SetSwitch
Browse files Browse the repository at this point in the history
  • Loading branch information
f0x4c1d committed Aug 8, 2024
1 parent 2d40749 commit 5c591b8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
}
else
{
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
builder.Services.AddDbContext<MyDatabaseContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("AZURE_POSTGRESQL_CONNECTIONSTRING")));
builder.Services.AddStackExchangeRedisCache(options =>
Expand All @@ -21,6 +20,11 @@
});
}

// Add Npgsql.EnableLegacyTimestampBehavior and Npgsql.DisableDateTimeInfinityConversions in DbContext
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);


// Add services to the container.
builder.Services.AddControllersWithViews();

Expand Down

0 comments on commit 5c591b8

Please sign in to comment.