Auto creating the database on first start

This commit is contained in:
Zoe Roux 2020-02-08 17:10:59 +01:00
parent e670025514
commit 15833b519f
3 changed files with 6 additions and 7 deletions

View File

@ -2,7 +2,6 @@
using Kyoo.Models.Watch;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
namespace Kyoo.Controllers
{

View File

@ -16,6 +16,10 @@ namespace Kyoo
Console.WriteLine($"Running as: {Environment.UserName}");
using (IServiceScope serviceScope = host.Services.CreateScope())
{
serviceScope.ServiceProvider.GetService<DatabaseContext>().Database.EnsureCreated();;
// Use the next line if the database is not SQLite (SQLite doesn't support complexe migrations).
// serviceScope.ServiceProvider.GetService<DatabaseContext>().Database.Migrate();;
IPluginManager pluginManager = serviceScope.ServiceProvider.GetService<IPluginManager>();
pluginManager.ReloadPlugins();

View File

@ -48,9 +48,9 @@ namespace Kyoo
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DatabaseContext database)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
@ -94,10 +94,6 @@ namespace Kyoo
spa.UseAngularCliServer(npmScript: "start");
}
});
database.Database.EnsureCreated();;
// Use the next line if the database is not SQLite (SQLite doesn't support complexe migrations).
// database.Database.Migrate();;
}
}
}