Search code examples
wpfwcfentity-framework-4.1asp.net-membershipaspnetdb

Using Membership Provider DataBase with Entity Framework 4.1


I have made the database using ASP.Net Configuration(aspnet_regsql.exe tool) . I want to use EF 4.1 to write the Data Access Layer. (I'll then use it in a WCF service and consume services from a WPF application)

How can I use EF 4.1 to do that .....

So for a simple demo sake .. I want to write Functions for User Management

I know I have to use DataBase first (IN EF 4.1) approach .. but there are so many tables and usually Database entry is done using Stored Procedures(Or the classes provided by the Sql Membership Provider).... and when I add one user or role... Many tables get Updated simultaneously (Sp's does that) ... will EF 4.1 will do the same by examining the structure of database..

I cant write any code because I don't know how to start off (except I have made the database)

How can I mimic the same behavior using EF 4.1

Any pointers in this regard will be helpful.


Solution

  • I want to write Functions for User Management

    No you don't or at least you should not! Membership API is self contained. It contains whole logic for user management and that logic is divided between .NET and stored procedures. If you want to access the API through WCF either use Authentication Service directly or wrap the standard API calls into new WCF service without working directly with database.

    Direct access to membership database means breaking membership API contract and in most cases it also means creating less secure and less encapsulated solution. Standard membership and role classes cannot be mapped with EF back to membership database - you will have to create your own entities which will break the original encapsulation.

    If you just want to create custom authentication and you don't want to use anything from Membership API except the database you should create your own database for your exact requirements.