0

How to use the built-in users(System.Web.Security.MembershipUser) from asp.net mvc 4.5

template project ,

with any new model?

for example I want to make a Posts/Forum model with the registered MembershipUser(s) ,

how to do it using EF Code First ( using last version EF5 + Visual Studio 2011 express web beta) ?

Thanks

Zakos
  • 1,492
  • 2
  • 22
  • 41

1 Answers1

2

You will add Guid property to your Post and Forum which will reference your membership user. If you want to have referential integrity in database you will either create custom database initializer which will create referential constraint between your Posts and Forums tables and MembershipUsers table by executing custom SQL (similar to this) or you will add this referential constraint to EF migration. MembershipUser class cannot be mapped by EF.

The Guid property should contain value from ProviderUserKey of your membership user - that should be unique identifier of your user in case of default SqlMembershipProvider.

Community
  • 1
  • 1
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • Thanks for the reply , that was my alternative guess of the answer which I was hope to avoid . It would be great if they convert the built it tables into EF Code First , maybe in the future. – Zakos May 12 '12 at 14:06