Custom identity server ef migration project

19 Sep 2017

ef core identity server

Might be obsolete right now Created for .net core 1.0.1

# Source
# https://identityserver.github.io/Documentation/docsv2/ef/migrations.html

# Enable migrations
Enable-Migrations -ProjectName IdentityServer.DbUp -ContextAssemblyName IdentityServer3.EntityFramework -ContextTypeName ScopeConfigurationDbContext -StartUpProjectName IdentityServer.DbUp -MigrationsDirectory Migrations\ScopeConfiguration -ConnectionString "<connection_string>" -ConnectionProviderName System.Data.SqlClient
Enable-Migrations -ProjectName IdentityServer.DbUp -ContextAssemblyName IdentityServer3.EntityFramework -ContextTypeName ClientConfigurationDbContext -StartUpProjectName IdentityServer.DbUp -MigrationsDirectory Migrations\ClientConfiguration -ConnectionString "<connection_string>" -ConnectionProviderName System.Data.SqlClient
Enable-Migrations -ProjectName IdentityServer.DbUp -ContextAssemblyName IdentityServer3.EntityFramework -ContextTypeName OperationalDbContext -StartUpProjectName IdentityServer.DbUp -MigrationsDirectory Migrations\OperationalConfiguration -ConnectionString "<connection_string>" -ConnectionProviderName System.Data.SqlClient

# Add migrations
Add-Migration -StartUpProjectName IdentityServer.DbUp -Name InitialCreate -ConfigurationTypeName IdentityServer.DbUp.Migrations.ScopeConfiguration.Configuration -ConnectionString "<connection_string>" -ConnectionProviderName System.Data.SqlClient
Add-Migration -StartUpProjectName IdentityServer.DbUp -Name InitialCreate -ConfigurationTypeName IdentityServer.DbUp.Migrations.ClientConfiguration.Configuration -ConnectionString "<connection_string>" -ConnectionProviderName System.Data.SqlClient
Add-Migration -StartUpProjectName IdentityServer.DbUp -Name InitialCreate -ConfigurationTypeName IdentityServer.DbUp.Migrations.OperationalConfiguration.Configuration -ConnectionString "<connection_string>" -ConnectionProviderName System.Data.SqlClient

#Custom directory
Add-Migration -Name InitialIdentityServerPersistedGrantDbMigration -Context PersistedGrantDbContext -OutputDir Migrations/PersistedGrantDb -StartupProject IdentityServer.DbUp
Add-Migration -Name InitialIdentityServerConfigurationDbMigration -Context ConfigurationDbContext -OutputDir Migrations/ConfigurationDb -StartupProject IdentityServer.DbUp

EF Core Links
https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet#installation
https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell
http://docs.identityserver.io/en/release/quickstarts/8entityframework.html
http://www.michael-whelan.net/ef-core-101-migrations-in-separate-assembly/
https://codingblast.com/entityframework-core-idesigntimedbcontextfactory/
https://www.learnentityframeworkcore.com/migrations/commands/pmc-commands


Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.