forked from brunobritodev/JPProject.IdentityServer4.AdminUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
263fde0
commit d090866
Showing
6 changed files
with
49 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Backend/JPProject.Admin.Api/Configuration/AdminUiMigrationHelpers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using JPProject.Admin.Infra.Data.Context; | ||
using JPProject.EntityFrameworkCore.Context; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace JPProject.Admin.Api.Configuration | ||
{ | ||
public static class AdminUiMigrationHelpers | ||
{ | ||
/// <summary> | ||
/// Generate migrations before running this method, you can use command bellow: | ||
/// Nuget package manager: Add-Migration DbInit -context ApplicationIdentityContext -output Data/Migrations | ||
/// Dotnet CLI: dotnet ef migrations add DbInit -c ApplicationIdentityContext -o Data/Migrations | ||
/// </summary> | ||
public static async Task EnsureSeedData(IServiceScope serviceScope) | ||
{ | ||
var services = serviceScope.ServiceProvider; | ||
await EnsureSeedData(services); | ||
} | ||
public static async Task EnsureSeedData(IServiceProvider serviceProvider) | ||
{ | ||
await Infra.Data.Configuration.DbMigrationHelpers.CheckDatabases(serviceProvider, new JpDatabaseOptions() { MustThrowExceptionIfDatabaseDontExist = true }); | ||
|
||
using (var scope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope()) | ||
{ | ||
var eventStoreDb = scope.ServiceProvider.GetRequiredService<EventStoreContext>(); | ||
await Infra.Data.Configuration.DbMigrationHelpers.ConfigureEventStoreContext(eventStoreDb); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters