Closed steveplatz closed 11 years ago
@steveplatz I think I just fixed this 30 seconds ago. The entity framework was initializing all our collections to null. I made them initialize to an empty list with a constructor. Try this in 5 minutes when Azure syncs up.
I don't know why this is not working for you. I think this is a one to many relationship. I can add friend and show them on the friends page in a list.
I'm surprised that this would be a one to many relationship. Wouldn't the friendship go both ways, such that I can have many friends and they can also have many friends?
I guess I am looking at it different. I see it as me (one) has many friends. Every one person has many friends, I don't see it as many of me has many friends.
Yes the friendship goes both ways since the person being friended has to accept.
You're right with that, but if you look at the way the model is currently set up, the friendship is defined by the UserProfile_UserId column. So, if I were to add you as a friend, the database would look like this:
| UserId | UserName | UserProfile_UserId |
|--------|----------|--------------------|
| 1 | steve | null |
| 2 | geoff | 1 |
| 3 | jon | null |
|--------|----------|--------------------|
But how could you ever be linked as Jon's friend?
@geekpgh I also forgot to reply to you, but yes, the changes you made did fix the initial issue I was running into.
I took from an example online. I thought that the joined table would be hidden like for IngredientRecipe. Maybe I need to add this:
modelBuilder.Entity
for UserProfile. Because I just tried to add 3 friends to each other and it messed things up.
Got this to work as a one to many relationship
When I try to enumerate the friends collection for a user object, I get null reference exceptions. I also assume that friends is a many to many relationship, but don't see the join table that would be necessary to pull this off in the database. Is this something that still needs to be worked on?