diff --git a/src/Artemis.Storage/Repositories/ProfileRepository.cs b/src/Artemis.Storage/Repositories/ProfileRepository.cs index 77bc4efd8..cb1c826a9 100644 --- a/src/Artemis.Storage/Repositories/ProfileRepository.cs +++ b/src/Artemis.Storage/Repositories/ProfileRepository.cs @@ -14,6 +14,7 @@ namespace Artemis.Storage.Repositories public ProfileRepository() { _dbContext = new StorageContext(); + _dbContext.Database.EnsureCreated(); } public IQueryable GetAll() diff --git a/src/Artemis.Storage/Repositories/SettingRepository.cs b/src/Artemis.Storage/Repositories/SettingRepository.cs index 0b52aaee4..8564edbf8 100644 --- a/src/Artemis.Storage/Repositories/SettingRepository.cs +++ b/src/Artemis.Storage/Repositories/SettingRepository.cs @@ -14,6 +14,7 @@ namespace Artemis.Storage.Repositories internal SettingRepository() { _dbContext = new StorageContext(); + _dbContext.Database.EnsureCreated(); } public IQueryable GetAll() diff --git a/src/Artemis.Storage/Storage.db b/src/Artemis.Storage/Storage.db deleted file mode 100644 index b0641d32b..000000000 Binary files a/src/Artemis.Storage/Storage.db and /dev/null differ diff --git a/src/Artemis.Storage/StorageContext.cs b/src/Artemis.Storage/StorageContext.cs index 9b5f7ca84..275494767 100644 --- a/src/Artemis.Storage/StorageContext.cs +++ b/src/Artemis.Storage/StorageContext.cs @@ -1,4 +1,7 @@ -using Artemis.Storage.Entities; +using System; +using System.IO; +using System.Reflection; +using Artemis.Storage.Entities; using Microsoft.EntityFrameworkCore; namespace Artemis.Storage @@ -10,7 +13,14 @@ namespace Artemis.Storage protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseSqlite("Data Source=Storage.db"); +#if DEBUG + var dbLocation = Path.GetFullPath(Path.Combine(Assembly.GetEntryAssembly().Location, @"..\..\..\..\Artemis.Storage\Storage.db")); +#else + var dbLocation = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Artemis\\Storage.db"; +#endif + optionsBuilder.UseSqlite("Data Source=" + dbLocation); + + // Requires Microsoft.Data.Sqlite in the startup project SQLitePCL.Batteries.Init(); } diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index 1bd215c1e..41026e886 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -80,6 +80,9 @@ ..\packages\MaterialDesignThemes.2.5.1\lib\net45\MaterialDesignThemes.Wpf.dll + + ..\packages\Microsoft.Data.Sqlite.Core.2.2.4\lib\netstandard2.0\Microsoft.Data.Sqlite.dll + ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll @@ -107,6 +110,18 @@ ..\packages\RGB.NET.Groups.0.1.22\lib\net45\RGB.NET.Groups.dll + + ..\packages\SQLitePCLRaw.bundle_green.1.1.12\lib\net45\SQLitePCLRaw.batteries_green.dll + + + ..\packages\SQLitePCLRaw.bundle_green.1.1.12\lib\net45\SQLitePCLRaw.batteries_v2.dll + + + ..\packages\SQLitePCLRaw.core.1.1.12\lib\net45\SQLitePCLRaw.core.dll + + + ..\packages\SQLitePCLRaw.provider.e_sqlite3.net45.1.1.12\lib\net45\SQLitePCLRaw.provider.e_sqlite3.dll + ..\packages\Stylet.1.1.22\lib\net45\Stylet.dll @@ -244,6 +259,12 @@ + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/packages.config b/src/Artemis.UI/packages.config index a1b5eaaae..67a7db653 100644 --- a/src/Artemis.UI/packages.config +++ b/src/Artemis.UI/packages.config @@ -8,6 +8,8 @@ + + @@ -18,6 +20,12 @@ + + + + + + \ No newline at end of file