3

How is everyone designing their EF models when using the built in ASP .NET Membership functionality?

I have many entities (blog posts, comments, photos, etc.) which have a user id associated with them. I currently have a User model that maps to the aspnet_User table, but there is lots of sketchy code juggling around both the MembershipUser entity and the User model which I've created.

Does anybody have any clever solutions I may be overlooking to merge the two entities while still using the included membership functionality?

inolen
  • 607
  • 1
  • 6
  • 10
  • 2
    Take a look at this Craig Stuntz's answer: http://stackoverflow.com/questions/1348173/how-would-you-use-entity-framework-1-0-with-asp-net-membership – Devart Sep 09 '10 at 12:48

1 Answers1

0

What I have done in this situation is to create a View in SQL Server, which selects from my own User table and joins one or two columns from the ASP.NET tables. I then map my User entity to this View using ToTable() in DbContext.

This works well enough for me; just note that you cannot use an UPDATE statement on a SQL View if it affects columns from more than one table, so the properties from the ASP.NET tables should not be modified via EF (how you enforce this depends on your implementation).

avesse
  • 771
  • 1
  • 9
  • 20