MVC4 - Membership - SQL Server Compact 4.0 - Exception: Unable to find the requested .Net Framework Data Provider

岁酱吖の 提交于 2019-12-04 19:24:47

Thank you to Scott Hanselman and whoever made him aware of the Membership Provider with SQLCE protocol as in his Introducing System.Web.Providers - ASP.NET Universal Providers for Session, Membership, Roles and User Profile on SQL Compact and SQL Azure blog post Scott outlines the steps to implement the ASP.NET Universal Providers. This helped me as he outlined the proper connection string outline for SQLCE:

<connectionstrings>
   <add name="Sql_CE" 
        connectionstring="Data Source=|DataDirectory|\MyWebSite.sdf;" 
        providername="System.Data.SqlServerCe.4.0">
   </add>
</connectionstrings>

So I updated my connectionstring to:

<connectionstrings>
   <add name="defaultconnection" 
        connectionstring="Data Source=|DataDirectory|\ce.sdf;" 
        providername="System.Data.SqlServerCe.4.0">
   </add>
</connectionstrings>

Then updated connectionStringName the ~/Filters/InitializeSimpleMembershipAttribute class back to:

WebSecurity.InitializeDatabaseConnection("defaultconnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);

The application compiled without an error or exception so I ran the application then Registered a user and in that process the applicable SimpleMembership tables were generated into my "ce.sdf" (SQL Server Compact 4.0 Local Database).

I am now able to utilize the SimpleMembership default's at their fullest!

p.s., For brevity I'm going to now edit my initial post/question to omit the stacktraces, leaving only the exceptions.

Random suggestion but it may need to be added.as a namespace to the web.config file or as a package in the packages file, I could be wrong

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!