Closed
Description
I have two entities Client and ClientRelation. ClientRelation only stores two Client foreign keys and their relation
ClientRelation looks like this
public class ClientRelation : Identifiable
{
[HasOne("client", Link.None)]
public virtual Client Client { get; set; }
public int ClientId { get; set; }
[HasOne("relatedClient", Link.None)]
public virtual Client RelatedClient { get; set; }
public int RelatedClientId { get; set; }
[Attr("relationship")]
public RelationshipEnum Relationship { get; set; }
}
After upgrade to version 2.3.2 or 2.3.3, POST on this entity throws exception:
System.Data.SqlClient.SqlException: Cannot insert explicit value for identity column in table 'Clients' when IDENTITY_INSERT is set to OFF.
Post request looks like this:
{
"data": {
"attributes": {
"relationship":1
},
"relationships": {
"client": {
"data": {
"type": "clients",
"id": "1"
}
},
"relatedClient": {
"data": {
"type": "clients",
"id": "2"
}
},
},
"type": "client-relations"
}
}
In version 2.3.1 everything is OK. I think that is somehow caused by new method AttachHasOnePointers() in DefaultEntityRepository. Do you know, what could be a problem?