简体   繁体   English

EF6:在Sql Server DB的模型生成中无法识别外键

[英]EF6: Foreign keys are not recognized on model generation for Sql Server DB

I'm getting started with Entity Framework and I'm trying to generate a model based on an already existing database. 我开始使用Entity Framework,我正在尝试基于已有的数据库生成模型。 Most of the tables have foreign key references to other tables on unique identifiers that do not happen to be the primary key of the table. 大多数表都具有对唯一标识符上的其他表的外键引用,这些表恰好不是表的主键。

It seems like the model generation is completely ignoring the FK references. 似乎模型生成完全忽略了FK引用。 The error list shows the following: 错误列表显示以下内容:

Error 6035: The relationship ' My foreign key constraint ' has columns that are not part of the key of the table on the primary side of the relationship. 错误6035:关系“ 我的外键约束 ”具有不属于关系主要一侧表的键的一部分的列。 The relationship was excluded. 这种关系被排除在外。

Here's a look at the model and error list 这是一个模型和错误列表

Anybody have any ideas? 有人有什么想法吗? Is it just that EF doesn't like FK constraints on fields that aren't the primary key? 是不是EF不喜欢FK约束对不是主键的字段?

Thanks in advance. 提前致谢。

实体框架不支持唯一的约束,遗憾的是,它将PK作为唯一的候选密钥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM