Search code examples
asp.net-mvc-3sqlmembershipprovidersql-server-ce-4

How To Add MVC3 SqlMembershipProvider With SQLCE4


I'm not quite sure if this has been asked or discussed elsewhere but I'm trying to implement the SqlMembershipProvider but I also want to use SQLCE4. I feel that having to have not only two databases but having two separate "server" systems drive those databases is a bad design. So, my question is, anyone know how to setup a connection entry in the web.config for the SQLCE db that is created when using the EF4/MvcScaffolder? I have a custom MembershipProvider that implements the System.Web.Security.SqlMembershipProvider and would like to modify it to use the SQLCE db. If not, maybe I could modify it to use DbContext?

Thanks Ahead... Keith

UPDATE:

So, I have created a connection string:

<add name="ApplicationServices" connectionString="DataSource=|DataDirectory|MVC3BlogEngine.Models.MVC3BlogEngineContext.sdf" providerName="System.Data.SqlServerCe.4.0" />

But when I attempt to create a user using the string I get the following error:

"An error occurred while attempting to initialize a System.Data.SqlClient.SqlConnection object. The value that was provided for the connection string may be wrong, or it may contain an invalid syntax. Parameter name: connectionString"

Now, looking at my connection string, maybe the path is wrong. So, I will update it and post the result...

UPDATE 2:

I changed the connection string to have the absolute full path to the sdf file but still no luck. I'm assuming the provider is specific to SqlProvider when I need to somehow change it to SqlCe.4.0?


Solution

  • I recently ran a membership provider implementation for a small project using sqlce and this sqlce membership provider. It was a very small project but I had no problems with it.