Reputation: 79
Is there a way to find which class is ,,Parent" and which is ,,Child" in FK relation? I can't think of a method to reliably accomplish it by using reflection and I don't have any idea how to do this with metadata without parsing strings. I am looking for something which would return Type of a ,,Parent" object.
Upvotes: 0
Views: 57
Reputation: 2712
The Entity Framework Mapping Api is one way to do it. I think it is technically possible to do what you need directly against EF but the code is a nightmare. I recall just trying to look up the primary keys directly against EF and it was convoluted. This library will make you life a lot easier.
The only one thing it does not do is show you the child relations, just the Foregin Keys. So you will need to implement your own logic to get child relations.
Upvotes: 1