I have an ASP.NET MVC 3 project that I just created using the project template that includes the Membership provider all set up in a default manner. I’m now trying to configure the the project to utilize SQL Server CE as a data source. I’m following this blog article without much success.
http://weblogs.asp.net/scottgu/archive/2011/01/11/vs-2010-sp1-and-sql-ce.aspx
Half way down the article you’ll find the subheading “Walkthrough 2: Using EF Code-First with SQL CE and ASP.NET MVC 3”, which is the portion that I am trying to follow.
According to my understanding, all I should need to do is to configure my connection string in the web.config file so that it will utilize SQL Server CE. And as soon as I run the application and try to create a new user, the CE database file should automatically be created in my App_Data directory and I should be up and running. Granted this walkthrough is doing things a bit differently and is not using Membership Provider, but I should be pulling the underlying concepts from this and still having success. Instead I am getting an error when I try to create a new user saying that it could not find the data source.
I’m using the following for my connection string in the web.config file…
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=|DataDirectory|AppData.sdf"
providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
What am I doing wrong?
The standard membership provider only supports SQL Server, but you can use the new Universal Provider available via NuGet: http://nuget.org/packages/System.Web.Providers