This problem started appearing after I upgraded to Breeze 1.4.9.
I have the following entity:
public class ProjectMember
{
public int ProjectId { get; set; }
[ForeignKey("ProjectId")]
[InverseProperty("ProjectMembers")]
public Project Project { get; set; }
public int TeamMemberId { get; set; }
[ForeignKey("TeamMemberId")]
[InverseProperty("ProjectMembers")]
public TeamMember TeamMember { get; set; }
}
And its configuration:
public class ProjectMemberConfiguration : EntityTypeConfiguration<ProjectMember>
{
public ProjectMemberConfiguration()
{
HasKey(a => new { a.ProjectId, a.TeamMemberId });
// ProjectMember has 1 project, projects have many projectmember records
HasRequired(a => a.Project)
.WithMany(s => s.ProjectMembers)
.HasForeignKey(a => a.ProjectId)
.WillCascadeOnDelete(true);
}
}
The metadata looks:
I create this entity on the client side with the following:
manager.createEntity('ProjectMember', { projectId: projectId, teamMemberId: teamMemberId });
All good so far, however when this entity is saved back to the server it gets duplicated on the client side as shown belo (the screenshot below shows what is in the cache after saveChanges
succeeded
callback is reached.
QUESTION Why is Breeze duplicating this entity although it should not be allowed?
EDIT
I reverted back to Breeze 1.4.8 and the problem disappeared. Here is what the manager
contains after a save operation: