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
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:
You might also find this useful:
http://efmembership.codeplex.com/
https://github.com/OmidID/Ado.net-Entity-Framework-Membership-Provider
Comments
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.