0

I want to create small web app. I've read some articles about how to create custom membership provider, but something isn't clear to me. Can I create custom DB, map this DB with entity framework, or I have to use aspnetsql_tool.exe(not exactly)? The DB has table with users and it's in relationship with other table. So what would you recommend to me? Is it good approach to work with EF in custom provider? Thanks

2 Answers 2

1

You can create a custom DB and map it with EF. You don't need to use the tool that generates the database tables.

Go through this walk through: Custom Membership Provider

You need to remove the ODBC code and put in your EF code in there, that should take care of most of it.


You should take care to watch the data your context returns, if it is a global context, you might end up with out-of-date data.

EF Context Instantiation (just checked the link, doesn't seem to work anymore, but I'll leave it in here in case it comes back up)


Some links that helped me out:

http://dotnetunplugged.com/2011/04/05/openfaq-part-3-custom-membership-provider-in-entity-framework-code-first/


You might also find this useful:

http://efmembership.codeplex.com/

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

Sign up to request clarification or add additional context in comments.

Comments

1

Your custom membership provider can use any mechanism and DB structure you want, so Entity Framework is as appropriate here as any other ORM framework. If you go for aspnet_regsql.exe, you will get DB structure setup for you, but you won't be able to easily change this structure. Mapping this database using EF is not a good idea, as it may be changed in future versions of ASP.NET.

So I would say, you either choose default membership DB structure created by custom aspnet_regsql.exe or use your existing tables and imlpement custom provider yourself.

1 Comment

Thanks for answer. But one question yet. Can I use membership provider with form authentication? MememberShipProvider is same for mvc and webforms? Because App will be created in webform.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.