IdentityServer4.LinqToDB
is a persistence layer for IdentityServer4 configuration data that uses Linq To DB as it's database abstraction.
Project's source code is originally based on IdentityServer4.EntityFramework
- Release builds can be found on NuGet
- MyGet
- V2
https://www.myget.org/F/linq2db/api/v2
- V3
https://www.myget.org/F/linq2db/api/v3/index.json
- V2
Install package:
PM> Install-Package IdentityServer4.Contrib.Linq2db
All POCOs are under IdentityServer4.Contrib.LinqToDB.Entities
namespace. Mostly POCOs are inherited from IdentityServer4.Models.*
classes (to avoid unnesesary mapping), with adding only Id
properties for identities and foreign keys. IdentityServer4.Models.Client.ClientId
is used as promary key for Client
entity. All Id
's are identity by default.
Firstly you should create your connection factory as implementation of IdentityServer4.LinqToDB.Interfaces.IDataConnectionFactory
, for example:
public class MyConnectionFactory : IDataConnectionFactory
{
public DataContext GetContext() => new DataContext();
public DataConnection GetConnection() => new DataConnection();
}
In your Strartup.cs
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// ...
// create factory instance
var factory = new MyConnectionFactory();
services.AddIdentityServer() // Add IdentityServer
.AddTemporarySigningCredential()
// some other stuff
// Configure Linq To DB storage for IdentityServer
.AddConfigurationStore(factory)
.AddOperationalStore(factory);
// ...
return services.BuildServiceProvider(true);
}