Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net Membership - Providers in Entity Framework 4

I have a website using ASP.NET Membership, Entity Framework 4 in place and MS SQL 2008 for DB.

I would like to know if using ASP.NET Membership the interaction with the database will be pass using Entity Framework?

Thanks for your help!

like image 750
GibboK Avatar asked Sep 13 '10 13:09

GibboK


1 Answers

Upvoted on Musa's answer to remove the negative. There's no mention of custom membership provider, but that doesn't mean it isn't the answer.

He's spot on right, there is no EF4 specific provider shipped with the framework but you can build your own.

This actually consolidates the problem domain, in that you can CLEANLY link users into the rest of your entity objects rather than treating membership as a separate black box that you have to tip-toe around.

The way to do that is indeed by inheriting from MembershipProvider and implementing the abstract methods.

Once you've done that you can do whatever you want with users etc rather than living in fear of breaking the SQLMembership tables and stored procedures that you get by default - which I don't like using as they are ugly.

I've just done this, using my own EF4 model, with my own implementation of users etc. I used the sample code that came with this video - http://www.asp.net/general/videos/how-do-i-create-a-custom-membership-provider . BTW if you use that sample code as is, watch out for a couple of typos in stored procedure names!

like image 194
RichardW1001 Avatar answered Sep 20 '22 10:09

RichardW1001