membershipProvider="OmidIDMembershipProvider" and "Default Membership Provider could not be found"

Jun 26, 2012 at 1:35 AM

Hello. I had gotten your project working several times with various configurations of the Samples using my own databases.

But when I tried to get it working with my own project I was receiving "Default Membership Provider could not be found."

Like a blind man I just started stepping through the code (I am pretty new to MVC) and I got to about Line 61 in EFRoleProvider.cs, where the error would happen. It was not finding a value for "membershipProvider" in the config.

I added this value to the attributes of the "<add name="OmidIDRoleProvider"..." tag in the 

<roleManager enabled="true" defaultProvider="OmidIDRoleProvider">
      <providers>

That worked. I hope this helps someone else, or if this is not the right solution I hope someone can help me.

Thanks!

Jun 26, 2012 at 5:18 PM

After including the project in my solution and modifying the web.config I am able to get the EFMembership provider to work with my code and data. I can see in the code that it is the OmidIDMembershipProvider that is being used. 

I don't yet understand how to add columns to the Memebership User. I have FirstName and LastName added to the table and I have added the properties to the Default/AspNet/AspUser.cs file. But I think I am supposed to create this file in my project and then pass it to the EFMembershipProvider?

So the steps would be:

  1. Modify the web config to point to the OmidIDMembershipProvider and OmidIDRoleProvider.
  2. Create a User class and Role class that implement the base MembershipUser and Membership role and the UserRole join class (or dose it just need the base properties?).
  3. Create Mappers that maps all the properties and implements IUserMapper, IRoleMapper and IUserRoleMapper interfaces.
  4. Then it should be working?
Coordinator
Jun 26, 2012 at 6:19 PM

Hi.

Yes, you must set default provider or clear all of them and add a provider

<providers>
   </clear>
   <add ....

----------------------------------------------------------------------------------------

If you want to add custom column or if you have your custom database design, you have to create your models and then add it in your provider.

By the way if you want to add first name and last name only , you can use OldEf.

For example, download the source code and go to "OmidID.Web.Security.EFMembershipProvider\Default\OldEf" directory and take a look at those codes

Jun 26, 2012 at 7:13 PM

So I have my project using the OmidIDMembershipProvider and I have those OldEf codes in my project. How do I get the MembershipProvider to use the OldEf Classes? I think I am missing that part. Where does that happen?

Coordinator
Jun 28, 2012 at 12:08 PM

Hi,

Download package open Sample3, it use OldEf.

 

Bese,
Omid Mafakher