Ajout de la base de données SQLite
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using NLog;
|
||||
using NLog.Web;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Webzine.EntitiesContext;
|
||||
using Webzine.Repository;
|
||||
using Webzine.Repository.Contracts;
|
||||
|
||||
@@ -21,6 +23,9 @@ try
|
||||
|
||||
builder.Services.AddSingleton<ITitreRepository, LocalEntityRepository>();
|
||||
|
||||
builder.Services.AddDbContext<WebzineDbContext>(options =>
|
||||
options.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection")));
|
||||
|
||||
// NLog: Setup NLog for Dependency injection
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Host.UseNLog();
|
||||
@@ -31,6 +36,12 @@ try
|
||||
// le dossier wwwroot.
|
||||
app.UseStaticFiles();
|
||||
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var db = scope.ServiceProvider.GetRequiredService<WebzineDbContext>();
|
||||
db.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
// Active le middleware permettant le routage des requetes entrantes.
|
||||
app.UseRouting();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user