I have a legacy database with the table which has only one row without a primary key. When I try to update this row nothing happens. I searched a lot and came on this line of code (dbf.Entry(nextPro).State = EntityState.Modified;)
. When I added this code I got the error: "Unable to track an instance of type 'NxtId' because it does not have a primary key. Only entity types with primary keys may be tracked."
I cannot remove the row and add a new one. I cannot add primary key. I have the only option to update the row somehow.
var nextPro = dbf.NxtId.FirstOrDefault();
nextPro.ProductNo = 239071;
dbf.Entry(nextPro).State = EntityState.Modified;
dbf.SaveChanges();
Entity:
public partial class NxtId
{
public int? ProductNo { get; set; }
public int? Uid { get; set; }
[Key]
public int? SatCode { get; set; }
}