开发者

Parent-child hierarchy

开发者 https://www.devze.com 2023-01-14 11:47 出处:网络
I have a 2 tables in database: Person and child. They are hierarchy it means my child table has an Id that is PRIMARY KEY but not auto incremental.this Id fill by Id of Parent table

I have a 2 tables in database: Person and child. They are hierarchy it means my child table has an Id that is PRIMARY KEY but not auto incremental.this Id fill by Id of Parent table

I have created a EDMX from these bu开发者_运维百科t when I want to save a child I can't see the fields of parent in my child class in EF it's not supported?

I want to do it like in NHIBERNATE. please help me - what should I do?


Probably you shoud just write something like

ChildInstance.Parent = ParentInstance;

By this assignment you set the necessary relationship explicitly. You don't need to assign key properties manually in EF.

0

精彩评论

暂无评论...
验证码 换一张
取 消