Can I extend the IdentityServer 4 models?

asp.net-core entity-framework entity-framework-core identityserver4

Question

I am working on a project using ASP.Net Core and Identity Server 4. The project is using Entity Framework Core in order to store the Identity Server models.

Identity Server generates its own DbContexts (ConfigurationDbContext and PersistedGrantsDbContext) and these contexts are injected in the Startup file of the project, like so:

Startup.cs

var identityServer =  services.AddIdentityServer()
            .AddTemporarySigningCredential()
            .AddConfigurationStore(builder => builder.UseSqlServer(connectionString,
                options => options.MigrationsAssembly(migrationsAssembly)))
            .AddOperationalStore(builder => builder.UseSqlServer(connectionString,
                options => options.MigrationsAssembly(migrationsAssembly)))
            .AddAspNetIdentity<ApplicationUser>()
            .AddProfileService<IdentityProfileService>();

For the purposes of the project all of our models use a row version property in order to catch any concurrency issues during update.

Property definition in the model

     /// <summary>
    /// Concurrency stamp for model
    /// </summary>
    [Timestamp]
    public byte[] RowVersion { get; set; }

The question is, how can we extend the default models of IdentityServer 4? Also, should we even try to extend those models?

I am open to any advice, suggestions and alternatives.
Thank you.

1
2
9/12/2017 2:41:47 PM

Popular Answer

You could create derived classes add your RowVersion field to those. You will need to create a whole other data access layer to read and write to the database since the built in ConfigurationDbContext could not use those derived classes.

I might be inclined to create my own models and use Dapper for my own administrative functionality like this.

0
9/15/2017 3:56:02 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow