Deprecated: This repository is no longer in active development or maintenance. Use the official library instead: IdentityServer3.EntityFramework
Entity Framework 7 persistence layer for IdentityServer v3
The primary key type can be configured for ClientStore and ScopeStore. To facilitate this, subclass the ClientConfigurationContext<TKey>
and ScopeConfigurationContext<TKey>
with the desired key type.
public class ClientConfigurationContext : ClientConfigurationContext<Guid>
{
public ClientConfigurationContext(DbContextOptions options)
: base(options)
{ }
}
public class ScopeConfigurationContext : ScopeConfigurationContext<Guid>
{
public ScopeConfigurationContext(DbContextOptions options)
: base(options)
{ }
}
In the Startup.cs
, register your DbContexts with Entity Framework
public void ConfigureServices(IServiceCollection services)
{
...
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ClientConfigurationContext>(o => o.UseSqlServer(connectionString))
.AddDbContext<ScopeConfigurationContext>(o => o.UseSqlServer(connectionString))
.AddDbContext<OperationalContext>(o => o.UseSqlServer(connectionString));
...
}
Configure the IdentityServerServiceFactory
to use the EF stores.
public void Configure(IApplicationBuilder app)
{
...
var factory = new IdentityServerServiceFactory();
factory.ConfigureEntityFramework(app.ApplicationServices)
.RegisterOperationalStores()
.RegisterClientStore<Guid, ClientConfigurationContext>()
.RegisterScopeStore<Guid, ScopeConfigurationContext>();
owinAppBuilder.UseIdentityServer(new IdentityServerOptions
{
...
Factory = factory,
...
});
...
}