|
|
|
|
@ -41,9 +41,9 @@ namespace MyCompanyName.MyProjectName.Data
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!await MigrationsFolderExists())
|
|
|
|
|
if (await DbMigrationsProjectExistsAsync() && !await MigrationsFolderExistsAsync())
|
|
|
|
|
{
|
|
|
|
|
await AddInitialMigration();
|
|
|
|
|
await AddInitialMigrationAsync();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -108,14 +108,21 @@ namespace MyCompanyName.MyProjectName.Data
|
|
|
|
|
await _dataSeeder.SeedAsync(tenant?.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<bool> MigrationsFolderExists()
|
|
|
|
|
private async Task<bool> DbMigrationsProjectExistsAsync()
|
|
|
|
|
{
|
|
|
|
|
var dbMigrationsProjectFolder = GetDbMigrationsProjectFolderPath();
|
|
|
|
|
|
|
|
|
|
return dbMigrationsProjectFolder != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<bool> MigrationsFolderExistsAsync()
|
|
|
|
|
{
|
|
|
|
|
var dbMigrationsProjectFolder = GetDbMigrationsProjectFolderPath();
|
|
|
|
|
|
|
|
|
|
return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "migrations"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task AddInitialMigration()
|
|
|
|
|
private async Task AddInitialMigrationAsync()
|
|
|
|
|
{
|
|
|
|
|
Logger.LogInformation("Creating initial migration...");
|
|
|
|
|
|
|
|
|
|
@ -147,7 +154,7 @@ namespace MyCompanyName.MyProjectName.Data
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string GetDbMigrationsProjectFolderPath()
|
|
|
|
|
private string GetDbMigrationsProjectFolderPath()
|
|
|
|
|
{
|
|
|
|
|
var slnDirectoryPath = GetSolutionDirectoryPath();
|
|
|
|
|
|
|
|
|
|
@ -162,7 +169,7 @@ namespace MyCompanyName.MyProjectName.Data
|
|
|
|
|
.FirstOrDefault(d => d.EndsWith(".DbMigrations"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string GetSolutionDirectoryPath()
|
|
|
|
|
private string GetSolutionDirectoryPath()
|
|
|
|
|
{
|
|
|
|
|
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
|
|
|
|
|
|
|
|
|
|