I want to create a relationship between a custom table (Websites) and the default aspnet tables related to Users.
I’m using code-first so for most FK relationships I would just do
public ModelName ModelName { get; set; }
With this, EF will automatically create the FK relationships. Very easy.
What’s confusing is the most effective way to hook into the aspnet users/membership table. Do I create a new model Users that acts as an interface so that I can implement custom user code?
Is there a best way to do this that fits well into EF best practices? I basically just want to relate a user to the Websites table/model so that EF can do its thing.
This has few preconditions:
If you want your model class to have relation with ASP.NET table you must model ASP.NET table as another entity. I’m not sure if you can use ASP.NET classes for that because for example
MembershipUserdoesn’t have parameterless public constructor which is required for EF. So you will most probably need to create duplicate classes and their mappings and use these classes when referencing ASP.NET entities.