Base solution for your next web application
Open Closed

adding users to a custom entity with a many to many relation #1048


User avatar
0
patrickglaudemans created

Hi There!

As mentioned in the header I have a custom entity which is some sort of group to which I want to be able to add abpusers. In public class User : AbpUser<Tenant, User> (part of zero in core lib) I added: public List<ContentGroup> ContentGroups { get; set; } and in the custom entity: public List<User> Users { get; set; }

Entity framework created link tables and so far so good. But - no records are inserted after a contentGroup.Users.Add(existingUser) check this piece of code: var user = await UserManager.GetUserByIdAsync(System.Convert.ToInt64(selection)); contentGroup.Users.Add(user); if (contentGroup != null) { await _contentGroupRepository.UpdateAsync(contentGroup);
}

etc.

In the same entity I have another property Reports that is setup exact the same way: it has Reports and Report has ContentGroups (many to many). It works with the report entity..

I think it has something to do with the entity user which is not attached to the build in repository. Can you help me out?

Thanks, P


No answer yet!