h bob
h bob

Reputation: 3780

Use SQL Server Compact with ASP.NET Identity

I'm using the latest ASP.NET MVC, Identity and Entity Framework.

The sample Identity project uses Sql Server Express. I want to use Sql Server Compact.

What I did:

Problem is, when ApplicationDbContext is accessed for the first time (during seeding, in the ApplicationDbInitializer.InitializeIdentityForEF() method):

I thought it would be as simple as changing the connection string - so what am I doing wrong? Or put differently, how do I convert the solution from SQL Server Express to SQL Server Compact?

Upvotes: 5

Views: 1596

Answers (1)

h bob
h bob

Reputation: 3780

Found the error. My connection string was wrong, I had:

<add name="Foo"
     providerName="System.Data.SqlServerCe.4.0"
     connectionString="
       Data Source=|DataDirectory|\Foo.sdf;
       Persist Security Info=false;
       "/>

which doesn't work (XML, so thought whitespace is ignored, it's not), whereas this does:

<add name="Foo"
     providerName="System.Data.SqlServerCe.4.0"
     connectionString="Data Source=|DataDirectory|\Foo.sdf;Persist Security Info=false;" />

Regardless, the question itself contains a step-by-step for using sqlce with Identity2. Maybe it'll help someone.

Upvotes: 4

Related Questions