From 15833b519fb19c9628c546d2ce4e805d2595bf16 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 8 Feb 2020 17:10:59 +0100 Subject: [PATCH] Auto creating the database on first start --- Kyoo/Controllers/LibraryManager.cs | 1 - Kyoo/Program.cs | 4 ++++ Kyoo/Startup.cs | 8 ++------ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Kyoo/Controllers/LibraryManager.cs b/Kyoo/Controllers/LibraryManager.cs index 127555f7..fc64f49a 100644 --- a/Kyoo/Controllers/LibraryManager.cs +++ b/Kyoo/Controllers/LibraryManager.cs @@ -2,7 +2,6 @@ using Kyoo.Models.Watch; using System.Collections.Generic; using System.Linq; -using Microsoft.EntityFrameworkCore; namespace Kyoo.Controllers { diff --git a/Kyoo/Program.cs b/Kyoo/Program.cs index d905c9cc..8e68ac1f 100644 --- a/Kyoo/Program.cs +++ b/Kyoo/Program.cs @@ -16,6 +16,10 @@ namespace Kyoo Console.WriteLine($"Running as: {Environment.UserName}"); using (IServiceScope serviceScope = host.Services.CreateScope()) { + serviceScope.ServiceProvider.GetService().Database.EnsureCreated();; + // Use the next line if the database is not SQLite (SQLite doesn't support complexe migrations). + // serviceScope.ServiceProvider.GetService().Database.Migrate();; + IPluginManager pluginManager = serviceScope.ServiceProvider.GetService(); pluginManager.ReloadPlugins(); diff --git a/Kyoo/Startup.cs b/Kyoo/Startup.cs index 128835fd..e8b16f05 100644 --- a/Kyoo/Startup.cs +++ b/Kyoo/Startup.cs @@ -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();; } } }