简体   繁体   English

尝试 Scaffold-DbContext 的问题

[英]Issue trying to Scaffold-DbContext

I've never seen this issue before.我以前从未见过这个问题。 When I attempt to Scaffold-DbContext from MSSQL server I am able to connect just fine, but I'm getting an error about a foreign key in a table that was deleted from the database several weeks ago.当我尝试从 MSSQL 服务器连接 Scaffold-DbContext 时,我可以正常连接,但是我收到一个关于几周前从数据库中删除的表中的外键的错误。 The table it is seeing is called ServiceTicket, I have a similar table named ServiceTickets and I've ensured all the foreign keys are set appropriately.它看到的表称为 ServiceTicket,我有一个类似的表,名为 ServiceTickets,并且我确保所有外键都已正确设置。 Any help is appreciated.任何帮助表示赞赏。

exact error I'm getting:我得到的确切错误:

The foreign key {'ServiceTypeId'} cannot be added to the entity type 'ServiceTicket' because a foreign key on the same properties already exists on entity type 'ServiceTicket' and also targets the key {'ServiceTypeId'} on 'ServiceType'.无法将外键 {'ServiceTypeId'} 添加到实体类型“ServiceTicket”,因为实体类型“ServiceTicket”上已存在相同属性的外键,并且还针对“ServiceType”上的键 {'ServiceTypeId'}。

the table names we actually have in the db are ServiceTickets and ServiceType我们在数据库中实际拥有的表名是 ServiceTickets 和 ServiceType

Foreign Key Def外键定义

Also I've already tried deleting and re-creating the relationship另外我已经尝试过删除并重新创建关系

After triple checking all the keys there was indeed a second key for the same relationship that was causing the issue.在对所有键进行三次检查后,确实有第二个键用于导致问题的相同关系。

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

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