Q:

NerdDinner ASP Tutorial - Linq-to-Sql does not create collection for OneToMany

I'm trying to follow the ASP.NET Nerd Dinner tutorial of Microsoft, but I'm having problems with the linq-to-sql part.
I have the two databases Dinner and RSVP with primary keys and identity set to DinnerID and RsvpID. Then I created the relation FK_RSVP_Dinner with foreign key RSVP.DinnerID and pk Dinner.DinnerID
When creating the LinqToSql class and drag the two tables in, it creates the OneToMany relation successfully.

However, the NerdDinner.designer.cs file does not contain any collection called RSVPs, but only a variable RSVP.

What am I doing wrong?

A:

Couple of things to check:
Look in the NerdDinner.dbml's designer.cs file under the RSVP partial class definition and the Dinner partial class definition:
public partial class RSVP....

Make sure RsvpID is an Identity type of Primary Key with auto-generation of the key.

[Column(Storage="_RsvpID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]

A private EntityRef type should have been generated:

private EntityRef _Dinner;

Check the association property:
[Association(Name="Dinner_RSVP", Storage="_Dinner", ThisKey="DinnerID", OtherKey="DinnerID", IsForeignKey=true)]
public Dinner Dinner......

Do the same for the Dinner partial class...

Is the primary key correctly defined?
Is a EntitySet _Rsvps defined?
Is there and association defined:
[Association(Name="Dinner_RSVP", Storage="_RSVPs", ThisKey="DinnerID", OtherKey="DinnerID")]
public EntitySet RSVPs....

Hope that helps...

