Keep track of the data file's path

This commit is contained in:
tsommer committed 2022-07-17 12:54:37 +02:00
1 parent 22778fbcf6
commit 3ef7bf1784
1 file changed
+6 -1
+6 -1
View File
@@ -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>