ASP.NET Membership with Entity Framework

How does everyone design their EF models using the built-in membership function in ASP.NET?

I have many objects (blog posts, comments, photos, etc.) that have a user ID associated with them. I currently have a User model that maps to the aspnet_User table, but there is a lot of snippet code juggling around the MembershipUser object and the User model I created.

Does anyone have any smart solutions that I can ignore to combine the two objects while still using the functionality of the included membership?

+3
source share
1 answer

What I did in this situation was to create a view in SQL Server that selects from my own user table and joins one or two columns from ASP.NET tables. Then I map the User object to this view using ToTable () in the DbContext.

This is good enough for me; just note that you cannot use the UPDATE statement in an SQL view if it affects columns from more than one table, so properties from ASP.NET tables should not be changed using EF (how you do this depends on your implementation).

0
source

Source: https://habr.com/ru/post/1763894/


All Articles