Unique Keys not recognized by Entity Framework

Posted by David Pfeffer on Stack Overflow See other posts from Stack Overflow or by David Pfeffer
Published on 2010-01-26T17:40:22Z Indexed on 2010/04/06 22:23 UTC
Read the original article Hit count: 953

I have two tables, Reports and Visualizations. Reports has a field, VisualizationID, which points to Visualization's field of the same name via a foreign key. It also has a unique key declared on the field. VisualizationID is not nullable. This means the relationship has to be 0..1 to 1, because every Reports record must have a unique, not null Visualizations record associated with it.

The Entity Framework doesn't see it this way. I'm getting the following error:

Error 113: Multiplicity is not valid in Role 'Report' in relationship 'FK_Reports_Visualizations'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be *.

What's the problem here? How can I make the EF recognize the proper relationship multiplicity?

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about entity-framework-4