Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Can I specify the parent ID column to use for one-to-many relationship with EF code first?

$
0
0

Hi everyone, I am running into an issue using EF code-first migrations and lists of objects that share a same base class.  Here is what I have:

Post base class has Id and ParentPostId for tree data structure support
Question is a post
Answer is a post
Comment is a post

Question has a list of Comments
Answer has a list of Comments

When running add-migration, Comments lists have generated Question_Id and Answer_Id columns and indexes. I assume this is to allow a Comment post to have a many to one relationship with Answers/Questions. But I want to use the inherited ParentPostId for this relationship. Can anyone point me in the right direction for making this work the way I want when using EF code-first?

Thanks!


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>