Association end is not mapped in ADO entity framework

后端 未结 7 1795
爱一瞬间的悲伤
爱一瞬间的悲伤 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条回答
  • 2021-02-14 12:49

    Not sure of the answer, but I've just posted a similar question, which may at least help clarify the issue you are experiencing. Defining an Entity Framework 1:1 association

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-02-14 12:57

    There's not a lot of information in your question, but, generally speaking, this means that there is an incompletely defined association. It could be that you have tried to map one table with a foreign key to another table, but have not mapped that other table. You can also get this error when you try to do table per type inheritance without carefully following the steps for implementing that feature.

    0 讨论(0)
  • 2021-02-14 12:57

    Simply select the many relationship table (*) from the Association>Edit Mapping & select the appropriate relationship

    0 讨论(0)
  • 2021-02-14 12:58

    I had the exact same problem and this is what I did to fix it.

    Make sure you have an Entity Key set in your designer on the tables your making an association with. Also check that StoreGeneratedPattern is set to Identity for that Entity Key.

    0 讨论(0)
  • 2021-02-14 13:01

    The Entity Framework designer is terrible - I've had the same problem many times (and your problem too, Craig):

    This happens when you have a many-to-one association which is improperly setup. They could very easily fix the designer to make this process simple; but instead, we have to put up with this crap.


    To fix:

    • Click on the association, and go to the mapping details view.
    • Under association, click on Maps to <tablename>. Choose the table(s) which make up the many side of the relationship (ie. the table(s) which make up the *-side of the association in the designer)
    • Under Column, choose the table-columns which map to each entity-side Property. You get this error when one of those entries are blank.
    0 讨论(0)
提交回复
热议问题