I write class contents to base through EF, I describe through Code First.
public class LogRecord { [Key] public int Id { get; set; } public virtual LogDelivery LogDelivery {get;set;} } public class LogDelivery { public int Id { get; set; } public int LogRecordId { get; set; } public new ICollection<LogOrder> Orders { get; set; } public new ICollection<LogPrintedDoc> ResignDocs { get; set; } [Required] public virtual LogRecord LogRecord { get; set; } } Further other attachments are described (LogOrder, LogPrintedDoc, etc.) For one-to-many connections, for example for a Delivery-Order connection, everything works fine, the parent Id is specified.
For one-to-one communication, i.e. for a Record-Delivery connection, a 0 is always written to the Delivery table in the RecordId field.
Question: what is wrong? How to make EF write RecordId to the database?
LogDelivery.Id == 0, then 0 will be recorded - ixSciLogDeliveryIdtable is the foreign key? EF did that? Something I strongly doubt it, moreover, this field should not be Identity - ixSci