Reputation: 11
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. 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.
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'.
the table names we actually have in the db are ServiceTickets and ServiceType
Also I've already tried deleting and re-creating the relationship
Upvotes: 0
Views: 494
Reputation: 11
After triple checking all the keys there was indeed a second key for the same relationship that was causing the issue.
Upvotes: 1