I am currently migrating my .net application to PostgreSQL 15. Thus, I need to move all my tables from the public
schema to a custom schema.
My __EFMigrationHistory
table, also needs to be moved to the custom schema.
I have found the following way of controlling this:
services.AddDbContext<ApplicationDbContext>(options =>
options.UseNpgsql(
Configuration.GetConnectionString("DefaultConnection"),
x => x.MigrationsHistoryTable("__MyMigrationsHistory", "not-public")));
However, we configure our UseNpgsql()
from the appsettings.json
file. Something along the lines of:
public Startup(IConfiguration configuration, IWebHostEnvironment environment)
{
Configuration = configuration;
Environment = environment;
}
private IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<DataContext>(options =>
{
options.UseNpgsql(Configuration);
});
}
While our appsettings.json
looks as follows:
"Postgres": {
"Client": {
"Server": "localhost",
"Port": "5433",
"Database": "mydatabase",
"Username": "xxx",
"Password": "xxx",
"Include Error Detail": true
}
},
Is it possible to configure this in the appsettings.json
file? If yes, how?