Switch to SQLite

This commit is contained in:
Robert McRackan 2019-11-15 16:34:16 -05:00
parent 5474446f62
commit e319326c30
5 changed files with 50 additions and 3 deletions

View File

@ -6,6 +6,9 @@ namespace DataLayer
public class LibationContextFactory : DesignTimeDbContextFactoryBase<LibationContext> public class LibationContextFactory : DesignTimeDbContextFactoryBase<LibationContext>
{ {
protected override LibationContext CreateNewInstance(DbContextOptions<LibationContext> options) => new LibationContext(options); protected override LibationContext CreateNewInstance(DbContextOptions<LibationContext> options) => new LibationContext(options);
protected override void UseDatabaseEngine(DbContextOptionsBuilder optionsBuilder, string connectionString) => optionsBuilder.UseSqlServer(connectionString); protected override void UseDatabaseEngine(DbContextOptionsBuilder optionsBuilder, string connectionString) => optionsBuilder
//.UseSqlServer
.UseSqlite
(connectionString);
} }
} }

View File

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace DataLayer.Utilities
{
public static class LocalDatabaseInfo
{
public static List<string> GetLocalDBInstances()
{
// Start the child process.
using var p = new System.Diagnostics.Process
{
StartInfo = new System.Diagnostics.ProcessStartInfo
{
UseShellExecute = false,
RedirectStandardOutput = true,
FileName = "cmd.exe",
Arguments = "/C sqllocaldb info",
CreateNoWindow = true,
WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
}
};
p.Start();
var output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
// if LocalDb is not installed then it will return that 'sqllocaldb' is not recognized as an internal or external command operable program or batch file
return string.IsNullOrWhiteSpace(output) || output.Contains("not recognized")
? new List<string>()
: output
.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)
.Select(i => i.Trim())
.Where(i => !string.IsNullOrEmpty(i))
.ToList();
}
}
}

View File

@ -1,6 +1,7 @@
{ {
"ConnectionStrings": { "ConnectionStrings": {
"LibationContext": "Server=(LocalDb)\\MSSQLLocalDB;Database=DataLayer.LibationContext;Integrated Security=true;", "LibationContext_sqlserver": "Server=(LocalDb)\\MSSQLLocalDB;Database=DataLayer.LibationContext;Integrated Security=true;",
"LibationContext": "Data Source=LibationContext.db;Foreign Keys=False;",
"// on windows sqlite paths accept windows and/or unix slashes": "", "// on windows sqlite paths accept windows and/or unix slashes": "",
"MyTestContext": "Data Source=%DESKTOP%/sample.db" "MyTestContext": "Data Source=%DESKTOP%/sample.db"

View File

@ -1,6 +1,8 @@
-- begin VERSIONING --------------------------------------------------------------------------------------------------------------------- -- begin VERSIONING ---------------------------------------------------------------------------------------------------------------------
https://github.com/rmcrackan/Libation/releases https://github.com/rmcrackan/Libation/releases
v3.0.3 : Switch to SQLite
v3.0.2 : Final using LocalDB
v3.0.1 : Legacy inAudible wire-up code is still present but is commented out. All future check-ins are not guaranteed to have inAudible wire-up code v3.0.1 : Legacy inAudible wire-up code is still present but is commented out. All future check-ins are not guaranteed to have inAudible wire-up code
v3.0 : This version is fully powered by the Audible API. Legacy scraping code is still present but is commented out. All future check-ins are not guaranteed to have any scraping code v3.0 : This version is fully powered by the Audible API. Legacy scraping code is still present but is commented out. All future check-ins are not guaranteed to have any scraping code
-- end VERSIONING --------------------------------------------------------------------------------------------------------------------- -- end VERSIONING ---------------------------------------------------------------------------------------------------------------------

View File

@ -13,7 +13,7 @@ only files:
no mdf, ldf no mdf, ldf
REPLACE DB REPLACE DB
need completely need db? replace LocalDb with sqlite? embedded document nosql? need completely new db? replace LocalDb with sqlite? embedded document nosql (LiteDB)?
CREATE INSTALLER CREATE INSTALLER
see REFERENCE.txt > HOW TO PUBLISH see REFERENCE.txt > HOW TO PUBLISH
@ -24,6 +24,7 @@ Warn of known performance issues
- Tag add/edit - Tag add/edit
- Grid is slow to respond loading when books aren't liberated - Grid is slow to respond loading when books aren't liberated
- get decrypt key -- unavoidable - get decrypt key -- unavoidable
- images can take a bit to initially load. downloading is throttled as to not get the IP blocked by audible
-- end BETA --------------------------------------------------------------------------------------------------------------------- -- end BETA ---------------------------------------------------------------------------------------------------------------------
-- begin ENHANCEMENT, IMPORT UI --------------------------------------------------------------------------------------------------------------------- -- begin ENHANCEMENT, IMPORT UI ---------------------------------------------------------------------------------------------------------------------
@ -124,6 +125,8 @@ move out of Book and into DtoMapper?
Extract file and tag stuff from domain objects. This should exist only in data layer. If domain objects are able to call EF context, it should go through data layer Extract file and tag stuff from domain objects. This should exist only in data layer. If domain objects are able to call EF context, it should go through data layer
Why are tags in file AND database? Why are tags in file AND database?
why use a relational db? i'm treating it like a nosql db. use LiteDB instead?
extract FileManager dependency from data layer extract FileManager dependency from data layer
-- end TAGS --------------------------------------------------------------------------------------------------------------------- -- end TAGS ---------------------------------------------------------------------------------------------------------------------