简体   繁体   中英

Serendipity with multiplicity? Composite Primary Key of 2 Foreign Keys in EF throws error

I am using Entity Framework 4.0 with Database First and come across the following problem. I have the following tables (simplified for visual purposes)

Table B contains a Composite Primary Key of 2 Foreign Keys.

SQL Server Tables A,B,C

A            B                 C
A_ID(PK)<----A_ID(PK)(FK)      C_ID(PK)
             C_ID(PK)(FK)------^

When I update my model,

I see the relationships in my model browser but for some reason Table B looks like:

A            B                 C
A_ID(PK)<----A_ID(PK)(FK)      C_ID(PK)
             C_ID(FK)----------^

and i get the following error:

Error 36 Error 113: Multiplicity is not valid in Role 'B' in relationship 'FK_B_A'. Because the Dependent Role refers to the key properties, the upper bound of the multiplicity of the Dependent Role must be 1. C:......MyDatabase.edmx 3776 11 MyABCProject

This one is worth your morning cup of coffee becoming cold.

Thanks alot!

转到模型浏览器,然后将C_ID添加到您的A_ID中,从而创建一个Composite Primary键。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM