Fix SQLite

This commit is contained in:
SpoinkyNL committed 2019-04-18 19:44:20 +02:00
1 parent 8f4bb37fa4
commit 4c6223046d
6 files changed
+43 -2

No files matched your search

@@ -14,6 +14,7 @@ namespace Artemis.Storage.Repositories
public ProfileRepository()
{
_dbContext = new StorageContext();
_dbContext.Database.EnsureCreated();
}
public IQueryable<ProfileEntity> GetAll()
@@ -14,6 +14,7 @@ namespace Artemis.Storage.Repositories
internal SettingRepository()
{
_dbContext = new StorageContext();
_dbContext.Database.EnsureCreated();
}
public IQueryable<SettingEntity> GetAll()
Binary file not shown.
+12 -2
View File
@@ -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();
}