I really could use some assistance with an idea I'm working on.
I need a many to many relationship between IdentityModel and BookModel.
Something like this.
Now in my code I have this in the IdentityModel.
public class ApplicationUser : IdentityUser
{
public virtual ICollection<Book> Books { get; set; }
...
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
...
public System.Data.Entity.DbSet<talkbooks.Models.Book> Books { get; set; }
}
And this in my Book Model
public class Book
{
public int Id { get; set; }
public string Name { get; set; }
public string Isbn { get; set; }
public virtual ICollection<ApplicationUser> Users { get; set; }
}
Now I want users to be able to select the books they own from the database (To keep it simple there is only one book in there right now and I want to use a dropdown list for selecting it) then have this stored in the database.
I thought about editing the already scaffolded ManageController to include a method that takes care of adding the books to their account.
Now when I create the database (code-first entity) it creates the Database as follows:
I left out DiscussionModel and MessageModel for the moment. Now I really need some help with the code needed to make this work inside the controller. I really have tried so much, and I keep failing, I know this is due to the fact I'm a beginner and lacking experience. So I want to learn from what you can teach me. All help is greatly appreciated!