Argument Exception thrown - An item with the same key has already been added

Jul 30, 2012 at 9:41 PM
Edited Jul 31, 2012 at 2:29 PM

I have created a brand new project in VS2010 with 3 entities and an associative table.  2 entities are related through the associative table.

However I have hit a problem when calling any entity code.  I get a Argument Exception with the message "An item with the same key has already been added".

The following entities have been created using the designer: 

Entity1 

ID [Int] Not Null - PK
Field 1 [VarChar] (50) Not Null

Entity2

ID [Int] Not Null - PK
Field 1 [VarChar] (50) Not Null

Entity3

ID [Int] Not Null - PK
Field 1 [VarChar] (50) Null

EntityAssociation

e1 [Int] Not Null
e2 [Int] Not Null

Relationships

Entity1.ID -> EntityAssociation.e1
Entity2.ID -> EntityAssociation.e2

NOTE: Entity3 is it's own standalone entity with no relationships.

EntityAssociation is my Associative table (green in the designer).

When I start the program (simple WinForm in C#) I call the following code in Form Load:

var x = new XXX.YYY.EFDAL.YYYEntities(@"Data Source=.\SQL2008;Initial Catalog=XXXYYY;Integrated Security=True");

var zz = x.Entity3.ToList();

 The ArgumentException exception occurs on the line:

this._entity3 = base.CreateObjectSet<XXX.YYY.EFDAL.Entity.Entity3>("Entity3");

in the property get for Entity3 in YYYEntities.Generated.cs.

Am I doing something wrong? Any thoughts?

I am desparate in need of a fix/workaround/any help for this.  I've added this as an issue now.

Thanks,

Andez