I started a new internet project with VS2012 and am trying to just restructure my project a bit and I can\'t seem to keep the SimpleMemberhsipProvider working. Basically, a
In case others are getting this error and the above solution doesn't work, like in my case. It said invalid child object when I tried to add in the assemblies markup. I had to specify the roleManager and membership tags as below. Once I did that the update-database worked.
<roleManager enabled="true" defaultProvider="SimpleRoleProvider">
<providers>
<clear/>
<add name="SimpleRoleProvider" type="WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData"/>
</providers>
</roleManager>
<membership defaultProvider="SimpleMembershipProvider">
<providers>
<clear/>
<add name="SimpleMembershipProvider"
type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData"/>
</providers>
</membership>
First way
Check the sphair's answer out (in current thread).
Second way
Add following assemblies to the web.config
:
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="WebMatrix.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="WebMatrix.WebData, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
</system.web>
Update
The WebMatrix.WebData
assembly contains a start up method to initialize Membership/Role providers and enable RoleManager (PreApplicationStartCode.Start
). But ASP.NET couldn't find that to run in your case. By adding these two lines of code, we force ASP.NET to search these assemblies for PreApplicationStartMethodAttribute(s)
.
I had the exact same error running at my hosting company (WinHost.com - they are excellent BTW).
My solution was to add to the web.config:
<appSettings>
<add key="enableSimpleMembership" value="true" />
</appSettings>
add the key to the Web.Config as the page:
http://devbla.wordpress.com/2013/07/03/corrigindo-o-erro-no-aspnet-the-role-manager-feature-has-not-been-enabled/
[]'s
Instead of adding the assemblies to the web.config as Mehdi Golchin suggests, an alternative is to change the assembly references on WebMatrix.Data and WebMatrix.WebData to CopyLocal=True.