Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modelBuilder.Entity<Book>()
- .HasMany<UserData>(s => s.user)
- .WithMany(c => c.book)
- .Map(cs =>
- {
- cs.MapLeftKey("bookID");
- cs.MapRightKey("userID");
- cs.ToTable("BookXUser");
- });
- modelBuilder.Entity<BookXUser>()
- .HasRequired<UserData>(s => s.user)
- .WithMany(g => g.bookXuser)
- .HasForeignKey<int>(s => s.userID);
- modelBuilder.Entity<BookXUser>()
- .HasRequired<UserData>(s => s.user)
- .WithMany(g => g.bookXuser)
- .HasForeignKey<int>(s => s.userID);
- The EntitySet 'BookUserData' with schema 'dbo' and table 'BookXUser' was already defined. Each EntitySet must refer to a unique schema and table.
- public class BookXUser : IEntityBase
- {
- public int ID { get; set; }
- public int bookID { get; set; }
- public virtual Book book { get; set; }
- public int userID { get; set; }
- public virtual UserData user { get; set; }
- public string bookShelf { get; set; }
- }
Add Comment
Please, Sign In to add comment