This is not a strange but expected behavior.
Consider the following model:
public class Entity1 { public int Id { get; set; } public ICollection<Entity2> Collection2 { get; set; } } public class Entity2 { public int Id { get; set; } public ICollection<Entity1> Collection1 { get; set; } }
This is a typical EF many-to-many association with an implicit join table. When you add entity1 to entity2.Collection1 , it also adds entity2 to entity1.Collection2 .
Now replace Entity1 = Entity2 = User . The result is your model.
Soon, this EF model creates a self many-to-many relationship through an implicit UsersUsers connection UsersUsers , so you get the behavior described.
Since your intent seems to be related to two one-to-many relationships, you should explicitly specify EF using the Fluent API:
public class UsersContext : DbContext { public DbSet<User> Users { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<User>().HasMany(e => e.Collection1).WithOptional(); modelBuilder.Entity<User>().HasMany(e => e.Collection2).WithOptional(); } }
Now everything will work as expected.
source share