SimpleMembership with custom database schema in ASP.NET MVC 4

前端 未结 7 965
闹比i
闹比i 2020-12-04 21:50

I want to enable the ASP.NET MVC 4\'s SimpleMembership API to integrate with my own database schema. I have a plain and simple table in my database called Users

7条回答
  •  遥遥无期
    2020-12-04 22:36

    You could create your own membership provider by extending the MembershipProvider. See Custom MembershipProvider in .NET 4.0 for more details. Using this approach, you would only need to implement the methods you need. This should help keep things more simple and wouldn't require you to add tables you don't need.

    The basic steps (taken from the linked SO answer) are:

    1. Create a new Class file (if you're not using a multi-layered system, in your project's Models folder) let's call it MyMembershipProvider.cs
    2. Inherit that class from System.Web.Security.MembershipProvider
    3. Automagically create the needed methods (period + space in the inherit class)

提交回复
热议问题