Posted By: jh71283 | Jan 16th @ 1:30 AM
page 1 of 1
Comments: 3 | Views: 1597
jh71283
jh71283
Throw new System.Beverage. OutOfCoffeeException​()
Hi All.

I'm trying to create an EF model of a database.

Every table has a composite key, comprising of a column name unique to that table (e.g. SupplierID) and a SystemID.
This is so that multiple systems can run off one database without crossing data.

However I just can't get the entity framework designer to live happily with my composite keys.

I keep getting the error

Error    1    Error 111: Properties referred by the Principal Role Suppliers must be exactly identical to the key of the EntityType Database1Model.Suppliers referred to by the Principal Role in the relationship constraint for Relationship Database1Model.SuppliersProducts. Make sure all the key properties are specified in the Principal Role. 
  C:\Users\John\Documents\Visual Studio 2008\Projects\EfExample2\EfExample2\Model1.edmx    68    11    EfExample2


I will post a small example project shortly, just in case it's something I'm doing wrong.


Any progress on this? I'm having the same problem now.

I have a couple of tables, Employees and SecurityClearance. There are no relationships defined in the SQL Server database. They both have composite keys and I get this error when creating an association between the two.

 

Error 1 Error 111: Properties referred by the Principal Role DLPSSECL must be exactly identical to the key of the EntityType Model.DLPSSECL referred to by the Principal Role in the relationship constraint for Relationship Model.DLPSSECLDLEPEM. Make sure all the key properties are specified in the Principal Role. C:\Documents and Settings\simonb\My Documents\Visual Studio 10\Projects\WpfApplication1\WpfApplication1\Model1.edmx 1 1 WpfApplication1

 

Properties referred by the Principal Role SecurityClearance must be exactly identical to the key of the EntityType Model. SecurityClearance referred to by the Principal Role in the relationship constraint for Relationship Model. SecurityClearanceEmployee. Make sure all the key properties are specified in the Principal Role.

 

Employee
CompanyID (Int16) PK
EmployeeID (Int32) PK
SecurityClearance (string)
Other data fields...

SecurityClearance
CompanyID (Int16) PK
SecurityClearance (string) PK
Other data fields...

 

Association is between SecurityClearance and Employee (1 to Many).

Mappings:

Maps to Employee
  SecurityClearance:
      CompanyID : Int16  <-> CopmanyID : smallint (key field on Employee table)
      SecurityClearance : String <->SecurityClearance : char (data field on Employee table)
  Employee
      CompanyID : Int16  <-> CopmanyID : smallint (key field on Emlpoyee table)
      EmployeeID : Int32  <->  EmployeeID : int (key field on Employee table)

 

Is creating an association in the EDMX on composite keyed tables like this supported? I've tried it in both EF v3.5 and EF v4.0 in the VS2010 beta and get the same error message when running model validation.

Cheers,

Simon

bap
bap

I have the exact same problem.  it doesn't appear entity framework likes composite keys.  very frustrating.

page 1 of 1
Comments: 3 | Views: 1597
Microsoft Communities