Search code examples
asp.netasp.net-mvc-3membershiprelation

Can i make relationship between default membership table and new table


I have created a new table in the membership database. Now I want to make a relationship with the _aspnet_Users_ table. I've made the relationship, but when I make an asp.net entity model from the database, the Model1.edmx shows the tables without relationship.

Is this possible ?


Solution

  • Here is what you are going to do : After adding the table to your database in server explorer or management studio and setting the relationship you should reopen the Model1.edmx and right click in the design area and click on Update model from database then check tables and click finish , visual studio will autpmatically add new tables and relationships to your Model.edmx

    And the problem is that you can not make a relationship between two table columns that none of them are key column !

    The aspnet_User is the primary key table and the Post table is the foriegn key table , so you should make the relationship between the UserID column of the aspnet_User table and a same type (uniqeidentifier) column in the Posts table which represents The user's ID who posted the post .