Dodałem sobie do użytkownika customową właściwość, aby połączyć w relację Usera z tabelą cardwords(relacja jeden do wielu)
public class ApplicationUser : IdentityUser
{
public ApplicationUser()
{
this.cardwords = new HashSet<CardWord>();
}
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
return userIdentity;
}
public ICollection<CardWord> cardwords { get; set; }
}
public class CardWord
{
[Key]
public int Id { get; set; }
public ApplicationUser User { get; set; }
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public DbSet<CardWord> cardwords { get; set; }
}
W jaki sposób mogę teraz odczytywać i dodawać nowe obiekty do właściwości cardwords?