I am trying to use Find() on a set of an EF class that has a foreign Key and 2 primary Keys, however I keep getting error.
This is my class:
public class dbDDV
{
[ForeignKey("dbf")]
[Column(Order = 0)]
public int id { get; set; }
[Key]
[Column(Order = 1)]
public DateTime D0 { get; set; }
[Key]
[Column(Order = 2)]
public DateTime D1 { get; set; }
public double V{ get; set; }
}
For a particular value of id, D0 and D1 I have been trying to use Find():
dbContext.mySetOfdbDDV.Find(myId,myD0,myD1)
The following is the error I receive:
System.ArgumentException: The number of primary key values passed must match number of primary key values defined on the entity.
What would be the correct approach for Find() on this case?
Only D0
and D1
are part of your composite primary key (not id
, as weird as that is, but I'm not here to judge your design). So you should only pass values for those 2 columns when invoking Find
dbContext.mySetOfdbDDV.Find(myD0,myD1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With