Association end is not mapped in ADO entity framework

后端 未结 7 1775
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-14 12:00

I am just starting out with ADO.net Entity Framework I have mapped two tables together and receive the following error:

Error   1   Error 11010: Association End          


        
7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-14 12:51

    I had this problem in the case where I was creating both many to 0..1 and 0..1 to 0..1 associations. One entity needed associations to multiple tables, and that entity did not have foreign keys defined for those tables.

    I had to do the table mappings step that is given in the accepted answer, but note that it wasn't only for many to many associations; it applied to all the types of associations I added for this entity.

    In the Mapping Details view, I had to select the entity with the non-foreign key ID columns to the various tables. This is not always the "many" side of the relationship. Only there was I able to map the related entity property to the appropriate property in the original entity. Selecting the "destination" entity would not allow me to select the properties that I needed to, and the error would still exist.

    So in short, I had to map using the table related to the entity that had the "non-foreign key" ID fields corresponding to the various entities' (and their tables') primary keys that I needed to associate.

    Entity A

    various other properties...

    • Id
    • ContactId
    • OrderId

    etc.

    Contact entity

    • Id
    • FirstName
    • LastName etc.

    In the mapping details, I selected Entity A's table. It then showed both ends of the association. I mapped its Entity A's Id property to its table's actual ID column (they had different names). I then mapped the Contact entity's Id field to the ContactId field on the A entity.

提交回复
热议问题