You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if you try to create a resource with a HasOne relationship to an object that has a ConcurrencyStamp property via the EF .IsConcurrencyToken() method you will likely get a DbUpdateConcurrencyException thrown. Many of the ASP.Net Core Identity classes have this concurrency check.
As a workaround, you need to identify the resources that enforce the concurrency check and manually fetch them from the database. You also need to prevent JADNC from attaching the relationship pointer. So, change this:
publicoverrideasyncTask<Relationship>CreateAsync(Relationshiprelationship){// this would need to implement something similar to the default// implementation, excluding any relationships that include the // concurrency stampAttachOtherRelationships();if(relationship.Role==null)thrownewJsonApiException(400,"Cannot create relationship without a Role");varrole=await_context.Roles.SingleOrDefaultAsync(r =>r.Id==relationship.Role.Id);if(role==null)thrownewJsonApiException(400,$"Role '{relationship.Role?.Id}' does not exist");// manually assign the Rolerelationship.Role=role;_relationships.Add(relationship);await_context.SaveChangesAsync();returnrelationship;}
The text was updated successfully, but these errors were encountered:
Currently, if you try to create a resource with a HasOne relationship to an object that has a ConcurrencyStamp property via the EF
.IsConcurrencyToken()
method you will likely get aDbUpdateConcurrencyException
thrown. Many of the ASP.Net Core Identity classes have this concurrency check.See this for details: dotnet/efcore#9166 (comment)
As a workaround, you need to identify the resources that enforce the concurrency check and manually fetch them from the database. You also need to prevent JADNC from attaching the relationship pointer. So, change this:
JsonApiDotNetCore/src/JsonApiDotNetCore/Data/DefaultEntityRepository.cs
Lines 85 to 92 in e22e101
To something along the lines of this:
The text was updated successfully, but these errors were encountered: