I have a one-to-many relationship with an order and some orderlines.
When updating the runtime from 2.0.? to NetCore 2.2.7 I have started to get this message:
System.InvalidOperationException: The property 'OrderId' on entity type 'OrderLineDto' has a temporary value. Either set a permanent value explicitly or ensure that the database is configured to generate values for this property.
Did anything change when updating, and what exactly is this error? In the OrderlineDto I do have an OrderId, but I have never done anything to maintain it, nor would I assume I should.
Simplified my code looks like this:
Order o = new OrderDto() {Foo = "Foo"};
o.Lines.Add(new OrderlineDto(whatever) {Bar = "Bar"});
_db.Orders.Add(o);
_db.SaveChanges();
OrderlineDto is database first and looks like this:
[Key]
[Column("Id_pk")]
public int Pk { get; set; }
public int OrderId { get; set; }
public virtual OrderDto Order { get; set; }
This also seems to still work on some computers, but not on others. So it could be a bad installation or something, but if a codechange could be made that solves it explicit then I am also interested in that.