Skip to content

Database support in Thinktecture IdentityServer

January 28, 2013

This is post 1 in a short 3 part series on describing the database support in v2 of Thinktecture.IdentityServer. The parts of this series are:

  1. Database support in Thinktecture IdentityServer (this post).
  2. EF migrations in Thinktecture IdentityServer.
  3. Integrating Thinktecture IdentityServer database with an existing database.

In v2 of IdentityServer we used EntityFramework (EF) CodeFirst as our data access framework. What this means is that if your database supports EF then you can use it with IdentityServer.

In the default configuration of the code, we’ve configured the application to use a SqlServerCompact 4.0 database so that it’s dirt simple to download the code and get started. This database configuration is done via the ~/configuration/connectionStrings.config and it puts the database in ~/App_Data/IdentityServerConfiguration.sdf:

<connectionStrings>
  <add name="IdentityServerConfiguration"
    connectionString="Data Source=|DataDirectory|\IdentityServerConfiguration.sdf"
    providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>

There are other connection strings in this file (name=”SqlServer” and name=”SqlCe”), but they’re there for my convenience when doing database migrations (which I’ll comment on in the next post). If you’d like to remove them you can — they’re not used in any way at runtime.

So, if you’d like to use another database other than SqlServerCompact, then it’s just a matter of changing the connection string and provider name. This is all you’d need to do:

<connectionStrings>
  <add name="IdentityServerConfiguration"
    connectionString="server=localhost;database=IdentityServerConfiguration;trusted_connection=yes;"
    providerName="System.Data.SqlClient" />
</connectionStrings>

These connection strings I’ve shown do far are only for the IdentityServer configuration database and are separate from the user account database. If you’re using the membership provider for the account store then that will be configured separately as any other another other membership provider would be configured.

HTH

5 Comments leave one →
  1. Vijay permalink
    January 29, 2013 5:41 pm

    i am trying to use a custom user repository (database) that identityserver can validate users against. Will that be covered in your discussion?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

%d bloggers like this: