C
C#9mo ago
Bastieww

Creating 2 one-to-one relationships with a composite foreign key, EF Code First

Hello everyone, I'm trying to make a database with 2 one-to-one relationships with a composite foreign key,, with this kind of structure : ProductWithColor (that has an Id), Size (that has an Id) and Stock (which has not Id, but a composite Key composed by ProductWithColorId and SizeId). This is code-first, so I'm trying to generate my database with this code I tried everything I found on the Internet, but I can't achieve this. Can anyone help ? Thanks !!
2 Replies
Angius
Angius9mo ago
Any particular reason to use a composite FK? It's doable, sure: https://stackoverflow.com/a/54443507/6042255
Bastieww
BastiewwOP9mo ago
the stock is a "function" of size + color, like we can have 5 XXL red shirts, but 4 XS red shirts i check that that may works, I'll try that, ty !
Want results from more Discord servers?
Add your server