Project Moved to GitHub

Project Description
ADO.Net Framework Code First Membership Provider
With YOUR OPTIONAL DATABASE DESIGN
Manage the Roles and User Accounts with Asp.
C#, VB.Net, F#, MVC, MVC2, MVC3, Asp.Net, WCF

source code = https://github.com/OmidID/Ado.net-Entity-Framework-Membership-Provider

 

PM> Install-Package EFMembership-WebMatrix

 

PM> Install-Package EFMembership

 

Last Version 2.0 (30/01/2012):

  • Fully customizable with your database
  • Converted to Entity Framework 4.2
  • Converted to Code First
  • Included AspNet Sql Database design
  • Old Version database design included
  • Default User and Role database design included
  • Hierarchically Database supported
  • Custom Data Mapper
  • Custom Data Context
  • Optional database table Prefix
  • Optional database table Schema
  • Optional to use Application name

Next Version:

  • Profile Provider
  • Session Provider

Use as the following example:
Open and edit your web.config or app.config. In the system.web section, add or replace the following code:

   <membership defaultProvider="OmidIDMembershipProvider">
      <providers>
        <clear/>
        <add name="OmidIDMembershipProvider"
            type="OmidID.Web.Security.EFMembershipProvider`2[
[OmidID.Web.Security.Default.DefaultUser,
OmidID.Web.Security.EFMembershipProvider],
                    [System.Int64]], OmidID.Web.Security.EFMembershipProvider" connectionStringName="ApplicationServices" tablePrefix="ef_" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"></add> </providers> </membership>
    <roleManager enabled="true" defaultProvider="OmidIDRoleProvider">
      <providers>
        <clear/>
          <add name="OmidIDRoleProvider"
            type="OmidID.Web.Security.EFRoleProvider`3[
[OmidID.Web.Security.Default.DefaultRole,
OmidID.Web.Security.EFMembershipProvider],
                     [OmidID.Web.Security.Default.DefaultUserRole,
OmidID.Web.Security.EFMembershipProvider],
                     [System.Int32]], OmidID.Web.Security.EFMembershipProvider" connectionStringName="ApplicationServices" tablePrefix="ef_" applicationName="/" /> </providers> </roleManager>

If you using Asp.Net database (aspnet_regsql). try this code:

 

     <membership defaultProvider="OmidIDMembershipProvider">
          <providers>
              <clear/>
              <add name="OmidIDMembershipProvider"
                   type="OmidID.Web.Security.EFMembershipProvider`2[
[OmidID.Web.Security.Default.AspNet.AspUser,
OmidID.Web.Security.EFMembershipProvider],
                             [System.Guid]], OmidID.Web.Security.EFMembershipProvider" connectionStringName="ApplicationServices" tablePrefix="aspnet_" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> </providers> </membership> <roleManager enabled="true" defaultProvider="OmidIDRoleProvider"> <providers> <clear/> <add name="OmidIDRoleProvider" type="OmidID.Web.Security.EFRoleProvider`3[
[OmidID.Web.Security.Default.AspNet.AspRole,
OmidID.Web.Security.EFMembershipProvider],
                            [OmidID.Web.Security.Default.AspNet.AspUserInRole,
OmidID.Web.Security.EFMembershipProvider],
                            [System.Guid]], OmidID.Web.Security.EFMembershipProvider" connectionStringName="ApplicationServices" tablePrefix="aspnet_" applicationName="/" /> </providers> </roleManager>

 

If using OLD version of EFMembership (0.9):

 

      <membership defaultProvider="OmidIDMembershipProvider">
          <providers>
              <clear/>
              <add name="OmidIDMembershipProvider"
                   type="OmidID.Web.Security.EFMembershipProvider`2[
[OmidID.Web.Security.Default.OldEf.EfUser,
OmidID.Web.Security.EFMembershipProvider],
                              [System.Int32]], OmidID.Web.Security.EFMembershipProvider" connectionStringName="ApplicationServices" tablePrefix="" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> </providers> </membership> <roleManager enabled="true" defaultProvider="OmidIDRoleProvider"> <providers> <clear/> <add name="OmidIDRoleProvider" type="OmidID.Web.Security.EFRoleProvider`3[
[OmidID.Web.Security.Default.OldEf.EfRole,
OmidID.Web.Security.EFMembershipProvider],
                           [OmidID.Web.Security.Default.OldEf.EfUserInRole,
OmidID.Web.Security.EFMembershipProvider],
                           [System.Int32]], OmidID.Web.Security.EFMembershipProvider" connectionStringName="ApplicationServices" tablePrefix="" applicationName="/" /> </providers> </roleManager>

 

and also no need to set the ado.net entity framework setting in your connection:

 

  <connectionStrings>
    <add name="ApplicationServices"
         connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=EFMembership;Integrated Security=True"
         providerName="System.Data.SqlClient" />
  </connectionStrings>

Now you have to install or create datebase :

 

var installer = new OmidID.Web.Security.Installer();
			
installer.MembershipProvider = System.Web.Security.Membership.Provider;
installer.RoleProvider = System.Web.Security.Roles.Provider;

//Install database:
var installed = installer.CreateIfNotExist();

 

Last edited May 17 at 6:38 PM by OmidID, version 30