Entity Framework 4.1 Code First has really simplified the start for an application. You can virtually start File>New Project>New Class and start creating your Model.
For those that are unaware, EF Code First has a “Initializer” mechanism where you have to set if you wish to drop the database to re-recreate based on your Model and Relationship, as well as DbModelBuilder conventions that you may have set on your DataContext Class.
But once Model is created, you most definitely want to quickly scaffold the application that you wish to create. This most definitely will involve ASP.NET Membership classes interaction. But since EF Code First Drops the database every time the model changes, you have to run aspnet_regsql each time the database is dropped. This is a big annoyance once you get hold of it.
EF Team is working on something like an evolution of this approach, but when that is available is a good guess.
If you are using SQL Server with your ASP.NET MVC Application, you are in luck!. Back since SQL Server 6.5(may be before that, I don’t know!), they used to ship something called a “Model” database. Whenever someone creates a new database in SQL Server, all the properties and tables of the “Model” database is inherited in the new database!.
So effectively you can run aspnet_regsql against your “Model” database in your development system and then each time Entity Framework creates a new database, it will inherit aspnet Application Service tables!
Now all that is remaining to do is to create sample users and roles. You can do this easily by inheriting a new class as :
And you need to add this to your Global.asax in “Application_Start” :
Let me know if this helps!
EDIT : You need to enable “Role Manager” in web.config for roles to work.