Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Entity Framework with ASP.NET Membership?

I'm creating (really, re-creating) an app that has existing user and other data in MS-Access databases. The data will be moved to SQL Server, and part of that involves migrating users. I want to use EF to do ORM, and I am pretty sure I know what the data model will be in SQL Server. I am new to EF but not to ASP.NET, and I'd like to take advantage of the Membership features in ASP.NET. I am thinking about several ways to do this and would like some advice. I've done only a little research about this idea thus far, maybe it's been answered elsewhere. So, here goes a cluster of related questions.

  1. Can EF work with directly with ASP.NET Membership through some class or namespace that I'm not aware of?

  2. If I transition users to the Membership system, to align their userids with data in other tables should I create another set of tables for user data atop the aspnet_* tables a la DotNetNuke?

  3. I want to avoid a situation where I use the built-in Membership functions for only user authentication and switch over to EF context when I'm working with user-tagged data. Seems clumsy to withdraw user info to bind to a column in a GridView by going into a Membership user for every row, but maybe that's what's needed? Do I need to suck it up and replicate the Membership classes in EF for data retrieval purposes?

  4. I was thinking of maybe implementing some kind of EF provider for Membership, on the idea that maybe then the provider could sit inside the overall EF data model. Is this crazy talk? (I've never written my own provider before)

Feel free to tell me I am not making any sense.

like image 224
oasasaurus Avatar asked Mar 06 '09 20:03

oasasaurus


People also ask

Does ASP.NET use Entity Framework?

Features of ASP.NET Entity FrameworkModels can be constructed from scratch and then used to generate new databases, or they can be generated from existing databases and then hand-edited. Entity Framework generates an EDM (Entity Data Model) from POCO (Plain Old CLR Object) entities to get/set data type properties.

Can I use Entity Framework with ASP.NET Core?

To use Entity Framework 6, your project has to compile against . NET Framework, as Entity Framework 6 doesn't support . NET Core. If you need cross-platform features you will need to upgrade to Entity Framework Core.

Is Entity Framework a part of .NET framework?

Entity Framework is an Object Relational Mapper (ORM) which is a type of tool that simplifies mapping between objects in your software to the tables and columns of a relational database. Entity Framework (EF) is an open source ORM framework for ADO.NET which is a part of . NET Framework.

How can add Entity Framework in ASP.NET MVC?

Right-click the Controllers folder in Solution Explorer, select Add, and then click New Scaffolded Item. In the Add Scaffold dialog box, select MVC 5 Controller with views, using Entity Framework, and then choose Add.

How does ASP.NET membership work?

ASP.NET membership therefore helps you manage user authentication in your Web sites. You can use ASP.NET membership with ASP.NET Forms authentication or with the ASP.NET login controls to create a complete system for authenticating users. ASP.NET membership supports facilities for: Creating new users and passwords.

What is ASP.NET membership provider?

The ASP.NET membership provider is a feature that enables ASP.NET developers to create Web sites that allow users to create unique user name and password combinations. With this facility, any user can establish an account with the site, and sign in for exclusive access to the site and its services.


1 Answers

Why not do it the other way around? You can implement your own Membership provider for asp.net, that uses the model you want/need.

If the features you need aren't a complete match with the built-in asp.net membership implementation, you can just roll your own provider. If you will use just a couple features, you will have to implement just a couple methods (you don't have to fill implementation for all the methods). If you need more features than it supports, using the membership provider might get in your way.

like image 106
eglasius Avatar answered Sep 27 '22 18:09

eglasius