MVC4 ExtendedMembershipProvider and entityframewor

2020-03-01 17:51发布

问题:

i want to be able to use the same database for the application as the asp membership details for forms authentication. I am currently using MVC4. When i started and added the system.web.providers to my project i got a seperate default connection. I have modified the string to point to the same database as that being used in my application (entityframework).

Should i expect the providers to autocreate the tables in this database i.e.

  • webpages_Membership
  • UserProfile
  • webpages_Roles
  • webpages_OAuthMembership

Currently I am getting...

To call this method, the "Membership.Provider" property must be an instance of "ExtendedMembershipProvider"

when i try and register a new user via the default mvc4 application template. And the tables are absent.

regards Tim

回答1:

the issue here is that the default mvc4 internet template is using simplemembership to manage membership/roles information. the code in the template has assumption of this and can only work with simplemembership. when you install universal providers the account controller code blows up since it cannot understand universal providers. look at this post which explains further on this scenario http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates.aspx



回答2:

I have the same issue,

however mine isn't solved, but many people say add this to your web.config

<add key="enableSimpleMembership" value="false"/>
<add key="autoFormsAuthentication" value="false"/>

and if that doesn't work try making the top one true as well.