Database support in Thinktecture IdentityServer
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:
- Database support in Thinktecture IdentityServer (this post).
- EF migrations in Thinktecture IdentityServer.
- 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
i am trying to use a custom user repository (database) that identityserver can validate users against. Will that be covered in your discussion?
Yep, that’s part 3. Stay tuned.
any idea when you plan to post it?
As soon as I get time :)
Here ya go: https://brockallen.com/2013/02/03/integrating-thinktecture-identityserver-database-with-an-existing-database/
Does it support Amazon Dynamo DB if I want to store all my user info and config on that.
Don’t know — never tried that database.
Any future plan for noSQl like amazon dynamodb?
No plans for us to implement one, but the user DB and config DB are all modeled with interfaces, so you could always implement your own storage. Let me know how it goes.
Good morning everyone,
I’m new to IdentityServer and trying to setup the web.config for it.
I’m trying to set it up to connect to Sql Server instead of Sql Server CE. at the bottom of the config, do i need the following element block?
…..
Can I leave this block out?
If not, should it be the following since it is using entity framework code first?
Thank you very much for your help on this
Hi Sam — for specific issues related to IdentityServer, it’s preferred if you post on the github issue tracker. Thanks.
https://github.com/thinktecture/Thinktecture.IdentityServer.v2/issues/
Also, there’s a wiki for common questions: https://github.com/thinktecture/Thinktecture.IdentityServer.v2/wiki