Error: Unable to determine the principal end of an association between the types

You may get this error if you have entities related to itself. For example, you have a tree hierarchy.

The same entity may have references to its parent. In such case when you execute the query the error is appeared.The simplest class that can raise the exception.

If you try to query the entity and include the root you’ll catch the exception.

In order to get rid of the exception you should change the entity as follows:

This will help LINQ to find principal in the relationship and execute the query.




No Comments


You can leave the first : )



Leave a Reply