Question

I am building a new asp mvc 4 project. And I have added in Application_Start()

 WebSecurity.InitializeDatabaseConnection(
                "DefaultConnection", 
                "UserProfile", 
                "UserId", 
                "UserName", 
                true);

And when I have started the application it created me default tables like on diagram. I have extended UserProfile to fit my needs.
On the diagram you can see that webpages_OAuthMembership & webpages_Membership tables are not in realtionship with any table.
Should I bind them to the UserProfile table by UserId as a FK or there is some reason to leave it like this?
I work with SimpleMembership for the first time.

enter image description here

Was it helpful?

Solution

I would say it is up to you, but I would not recommend it in my opinion.

The main considerations are:

  • All that the FKs will do is enforce referential integrity (they will not impact performance as much as carefully managing your indexes).
  • As far as I am aware, there are no scenarios within SimpleMembership that will break if you use referential integrity.
  • But as SimpleMembership creates the tables without the FKs, that is the way it has been tested to work; creating the FKs may therefore break some operations (however unlikely that is).

Therefore I don't create the FKs. I use the SimpleMembership, WebSecurity, Membership, Roles etc. classes to do all membership operations, meaning I never need to access the tables directly. This also means that if there are edge cases where the referential integrity would break the SimpleMembership provider, I am not at risk of coming across them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top