Lection 53, IdentityServer4 - Using LocalDb for IdentityServer4 and ASP.NET Identity

Опубликовано: 21 Август 2020
на канале: Stoyan Cheresharov
4,851
39

Lection 53, IdentityServer4 - Using LocalDB for IdentityServer4 and ASP.NET Identity

Using EntityFramework Core for configuration and operational data: https://identityserver4.readthedocs.i...

Migrations Overview: https://docs.microsoft.com/en-us/ef/c...

Applying Migrations: https://docs.microsoft.com/en-us/ef/c...

1. Switch to LocalDb
1.1. appsettings.json
"DefaultConnection": "Data Source=(LocalDb)\\MSSQLLocalDB;database=IdentityServer4.IdSrvQuickstart.FirstIdSrvAspNetIdentity;trusted_connection=yes;"

1.2. Startup.cs
options.UseSqlServer(

1.3. Redo the migrations

Make sure you have
1.3.1. dotnet add package Microsoft.EntityFrameworkCore.SqlServer
1.3.2. dotnet tool install --global dotnet-ef
1.3.3. dotnet add package Microsoft.EntityFrameworkCore.Design
1.3.4. dotnet ef migrations add CreateIdentitySchema -c ApplicationDbContext -o Data/Migrations

2. Update the database
dotnet ef database update

3. Use EF with IdentityServer4
dotnet add package IdentityServer4.EntityFramework

4. Adding Migrations
dotnet tool install --global dotnet-ef
dotnet add package Microsoft.EntityFrameworkCore.Design

4.1. dotnet ef migrations add InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb

4.2. dotnet ef migrations add InitialIdentityServerConfigurationDbMigration -c ConfigurationDbContext -o Data/Migrations/IdentityServer/ConfigurationDb

5. Change the stores in the Startup
5.1.
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
.AddConfigurationStore(options...
...

5.2. seed the DB in Startup from Config.cs

6. Run the App. The tables will be created and seeded with data from Config.cs
InitializeDatabase(app);
...
private void InitializeDatabase(IApplicationBuilder app)
{
using (var serviceScope = app.ApplicationServices.GetService...


Смотрите видео Lection 53, IdentityServer4 - Using LocalDb for IdentityServer4 and ASP.NET Identity онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Stoyan Cheresharov 21 Август 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 4,851 раз и оно понравилось 39 людям.