Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116908

Extend Entity Framwork add column to IdentiyServer4 clients table

I have a DbContext that is part of Identityserver4 I am quite new to entity-framework.

namespace IdentityServer4.EntityFramework.DbContexts 
{
public class ConfigurationDbContext : DbContext, IConfigurationDbContext, IDisposable
{
    public ConfigurationDbContext(DbContextOptions<ConfigurationDbContext> options, ConfigurationStoreOptions storeOptions);

    public DbSet<Client> Clients { get; set; }
    public DbSet<IdentityResource> IdentityResources { get; set; }
    public DbSet<ApiResource> ApiResources { get; set; }

    public Task<int> SaveChangesAsync();
    protected override void OnModelCreating(ModelBuilder modelBuilder);
}
}

namespace IdentityServer4.EntityFramework.Entities
{
public class Client
{
 // I want to add a column here
 ................

}

The thing is I would like to Extend the Client class which is basically the clients table in the database and add a new column. Is this possible?

I am not allowed to edit these files as they are part of the Identityserver4 dlls. The only thing i can think of would be to create my own db context and copy what IdentityServer does but this just seams like over kill and i am not sure if IdentityServer will be able to read from the new table.

The column in question that i am trying to add to the Client table. Is an app id identifying the third party developer who has is using the client. We need to be able to contact them in the even there is an issue with their client or what they are doing. In worst case ban developers who are miss behaving.

Upvotes: 3

Views: 1461

Answers (1)

Brad
Brad

Reputation: 4553

The Client class has a Properties dictionary that allows you to add client specific values.

From the docs - http://docs.identityserver.io/en/release/reference/client.html

Properties - Dictionary to hold any custom client-specific values as needed.

Upvotes: 4

Related Questions