The foreign key {'ClassExtId'} cannot be added to the entity type 'ClassInt' because a foreign key on the same properties already exists on entity type 'Instrument' and also targets the key {'ClassExtId'} on 'ClassExt'.
Let's say I have ClassFoo & ClassBar inheriting from ClassInt. Each one of them have a reference to the same column ClassExtId. Why is the entity framework core scaffolding (v3) complaining ?
my case is different but i got the same error too when i was trying to scaffold my existing old database. i'm, posting this answer just in case someone also had the same problem with me.
it's turn out that in my old database, some table have so many duplicate foreign key created by previous developer. you can check this in your sql server (i use sql server developer edition 2019)
In Object Explorer, right-click the table that will be on the
foreign-key side of the relationship and click Design.
The table opens in Table Designer.
From the Table Designer menu, click Relationships. you'll see all the foreign key defined for that table, in my case it was applicationID that duplicate. clean it up :
go to your table > expand it and go to Keys. delete the duplicate key there:
dotnet ef dbcontext scaffold
command and good luck!