Understanding ForeignKey attribute in entity framework code first

前端 未结 3 1867
你的背包
你的背包 2020-11-29 03:31

See the following post for some background:

Entity framework one to zero or one relationship without navigation property

I had always thought that Fore

3条回答
  •  無奈伤痛
    2020-11-29 04:08

    I think you were right (provided that I understand you right). [ForeignKeyAttribute] is used on the coresponding foreign key. Not on the primary key of your linked object.

    This is my object, and the foreign key is DeferredDataId

    Neither the Id within your object is the foreign key (it's primary key) nor the ID of the linked object is the foreign key (it's the primary key of the other side of the relation)

    Hope I understood you correctly :) Because I'm not sure.

提交回复
热议问题