当我试图从MSSQL服务器连接Scaffold-DbContext时,我能够很好地连接,但我在几周前从数据库中删除的表中的外键出现了错误。它看到的表名为ServiceTicket,我有一个类似的表,名为ServiceTickets,并且确保所有外键都被适当设置。
我搞错了:
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'.我们在db中实际拥有的表名是ServiceTickets和ServiceType。

另外,我已经尝试过删除和重新创建这种关系
发布于 2021-12-09 18:47:31
在对所有密钥进行三次检查之后,确实存在导致问题的同一关系的第二个键。
https://stackoverflow.com/questions/70292776
复制相似问题