Custom Membership Provider with EF

I am trying to implement a custom membership provider in ASP.NET MVC 3 with the Enitty Framework. For user data, I created a User class that contains all the login information and a few more. When I tried to implement MemberhipProvider, there were some methods that I need to implement that have the MemberhipUser parameter in the signature:

public override void UpdateUser(MembershipUser user) 

I know that I can make my User class inherit from the MembershipUser class, and that won't be a problem. But when I tried to inherit it, I could not set values ​​for readonly properties such as email and others.

Is there a way that these methods can accept an object of type User? Or maybe there is another approach to this?

+3
source share
1 answer

References

http://msdn.microsoft.com/en-us/library/ms152065.aspx

Custom MemberhipUser with only the necessary parameters

http://www.codeproject.com/Articles/165159/Custom-Membership-Providers

Answer

You can create MemberhipUser instances and pass properties (read-only or not) in the constructor, and then return a MemberhipUser instance.

There is a quote in the documentation for the MembershipUser class that helped me understand this better:

Creating a new MembershipUser object does not add a new membership user object to the membership data store.

If adding custom properties is important, that will require you to subclass MembershipUser.

: MemberhipUser

Linq-to-Sql, EF, .

, .

0

All Articles