2
good afternoon!
I have this many configuration for many in my project.
public class Usuario
{
public Usuario()
{
this.LocalTrabalho = new HashSet<LocalAtendimento>();
}
public virtual ICollection<LocalAtendimento> LocalTrabalho { get; set; }
}
public class LocalTrabalho
{
public LocalTrabalho ()
{
this.Usuarios = new HashSet<Usuario>();
}
public virtual ICollection<Usuario> Usuarios{ get; set; }
}
modelBuilder.Entity<LocalAtendimento>()
.HasMany<Usuario>(s => s.Usuarios)
.WithMany(c => c.LocalTrabalho)
.Map(cs =>
{
cs.MapLeftKey("LocalTrabalho_Seq");
cs.MapRightKey("Usuario_Seq");
cs.ToTable("LocalTrabalhoUsuario");
});
When I save a user it should only reference the workplace, but when saving it creates a new workplace in the workplace table, with the same data of the referenced workplace, someone knows how to solve?
Thank you.
Enter the code that makes the register.
– novic