Guest User

Untitled

a guest
Jun 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. modelBuilder.Entity<Book>()
  2. .HasMany<UserData>(s => s.user)
  3. .WithMany(c => c.book)
  4. .Map(cs =>
  5. {
  6. cs.MapLeftKey("bookID");
  7. cs.MapRightKey("userID");
  8. cs.ToTable("BookXUser");
  9. });
  10.  
  11. modelBuilder.Entity<BookXUser>()
  12. .HasRequired<UserData>(s => s.user)
  13. .WithMany(g => g.bookXuser)
  14. .HasForeignKey<int>(s => s.userID);
  15.  
  16. modelBuilder.Entity<BookXUser>()
  17. .HasRequired<UserData>(s => s.user)
  18. .WithMany(g => g.bookXuser)
  19. .HasForeignKey<int>(s => s.userID);
  20.  
  21. The EntitySet 'BookUserData' with schema 'dbo' and table 'BookXUser' was already defined. Each EntitySet must refer to a unique schema and table.
  22.  
  23. public class BookXUser : IEntityBase
  24. {
  25. public int ID { get; set; }
  26. public int bookID { get; set; }
  27. public virtual Book book { get; set; }
  28. public int userID { get; set; }
  29. public virtual UserData user { get; set; }
  30. public string bookShelf { get; set; }
  31. }
Add Comment
Please, Sign In to add comment