1:1 relationship problems with EF Model First

眉间皱痕 提交于 2019-12-31 03:51:07

问题


I'm trying to develop an application as Model-First with EF. I tried everything to accomplish a table-splitting pattern and a 1:1 relationship but looks like EF just doesn't let me.

Assuming I do use Model-First - is there a way to put a 1:1 relationship without messing with the generated files and EF giving that annoying:

Multiplicity is not valid in Role 'Blablalah' in relationship 'Blabalbala'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be *.

I already tried to set my FK's as Primary Keys on destination tables but still doesn't help.


回答1:


1:1 relationship is generally defined by having foreign key in the first table and then having it cascade on delete, in database design.

IE: Users table and UserProperties table. Users table would have a UserPropertiesId as the foreign key and UserProperties would essentially treat Users as many Users to one UserProperties. That's just how things are, and if you only select by Users table it isn't an issue.



来源:https://stackoverflow.com/questions/14016035/11-relationship-problems-with-ef-model-first

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!