EF 4.1 Update 1 Code First + ASP.NET Membership Provider
I watc开发者_如何学Ched the “Creating immersive data experiences with Entity Framework “ video from this year’s BUILD conference and wanted to build out a simple application to test out the new features of EF. But, I’d also like to use the ASP.NET Membership Provider for managing users and roles within my app and I am struggling to find a clean way to include it in my code first approach. Do you guys have any recommendations, suggestions, or examples on how this could be done?
I would recommend looking at the MVC3-Boilerplate project on GitHub as it has a good example of creating a custom membership provider that is implemented using EF Code First.
I found this NuGet package which has been very useful.
Quickstart sample for using Altairis Web Security, Entity Framework and Unity in MVC 3. Super easy membership user/role integration. When using this quickstart, the users and role part of your project is completely setup. You can signup, login, edit roles for users etc.
http://www.nuget.org/List/Packages/quickstart.mvc3.unity.ef.altairiswebsecurity
CodeFirstMembership may be what you are looking for.
Features:
- Based on GUID's
- Login either by entering Username or Email
- Username and Email are unique
- Uses nearly all features from SimpleMembershipProvider
- Code-First approach
- All membership fields can be renamed/changed/localized
- Easily extendable (add additional fields)
- VB.NET and C# versions available
Also, ShoelaceMVC is a great MVC3 starter project that implements CodeFirstMemebership and comes with a nice layout thanks to Twitter's Bootstrap.
精彩评论