Keep track of the data file's path
This commit is contained in:
1 file changed
+6
-1
@@ -11,6 +11,10 @@ public static class Setup
|
||||
private const string DB_READ_WRITE_MODE = "ReadWrite";
|
||||
private const string DB_READ_WRITE_CREATE_MODE = "ReadWriteCreate";
|
||||
|
||||
private static string usedDataFile = string.Empty;
|
||||
|
||||
public static string DataFile => Setup.usedDataFile;
|
||||
|
||||
/// <summary>
|
||||
/// Tries to migrate the data file.
|
||||
/// </summary>
|
||||
@@ -30,7 +34,8 @@ public static class Setup
|
||||
/// </summary>
|
||||
public static void AddDatabase(this IServiceCollection serviceCollection, string path2DataFile, bool createWhenNecessary = true)
|
||||
{
|
||||
serviceCollection.AddDbContext<DataContext>(options => options.UseSqlite($"Filename={path2DataFile};Mode={(createWhenNecessary ? DB_READ_WRITE_CREATE_MODE : DB_READ_WRITE_MODE)}"), ServiceLifetime.Transient);
|
||||
Setup.usedDataFile = path2DataFile;
|
||||
serviceCollection.AddDbContext<DataContext>(options => options.UseSqlite($"Filename={path2DataFile};Mode={(createWhenNecessary ? DB_READ_WRITE_CREATE_MODE : DB_READ_WRITE_MODE)};"), ServiceLifetime.Transient);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user