confighantering. connection t postgres. test av import
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
using Bibblan.Business.Services;
|
||||
using Bibblan.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Configuration.AddJsonFile($"appsettings.user.json", true, true);
|
||||
|
||||
var configSection = builder.Configuration.GetSection(BibblanOptions.Bibblan);
|
||||
BibblanOptions config = new();
|
||||
configSection.Bind(config);
|
||||
// Add services to the container.
|
||||
builder.Services.Configure<BibblanOptions>(
|
||||
builder.Configuration.GetSection(BibblanOptions.Bibblan));
|
||||
builder.Services.Configure<BibblanOptions>(configSection);
|
||||
|
||||
builder.Services.AddScoped<CalibreService, CalibreService>();
|
||||
|
||||
@@ -16,9 +20,9 @@ builder.Services.AddControllers();
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
|
||||
var db = "metadata.db";
|
||||
var connection = $"Data Source={db};Mode=ReadOnly;";
|
||||
builder.Services.AddDbContext<CalibreContext>(options => options.UseSqlite(connection));
|
||||
builder.Services.AddDbContext<SqliteCalibreContext>(options => options.UseSqlite($"Data Source={config.CalibreDb};Mode=ReadOnly;"));
|
||||
builder.Services.AddDbContext<PostgresCalibreContext>(options => options.UseNpgsql(config.BibblanConnection));
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
Reference in New Issue
Block a user