I try to use DDD to describe domain model and code first approach on mapping to database tables with entity framework (using fluent api). For example I have 2 entities: Clubs and Users. Club has many Users. And I need to add new User to Club.
class User
{
public string Name { get; set; }
public Club Club { get; set; }
}
class Club
{
public string ClubName { get; set; }
public ICollection<User> Members { get; set; }
public void AddNewMember(User user)
{
//..some logic and checks
Members.Add(user);
}
}
- So, should I load all users collection in Club to add new and save? Or it's excessively?
- What is the best way for modeling entities with big collections? Should I always load them? Or move then to another separate object?