I had a following structure:
User has many books in his history
which was translated to the following
class User { ICollection<Book> History } // C#
User -> UserHistory (UserId, BookId) -> Book // DB
Now I want to add a date to the history, creating the following class structure:
class User { ICollection<Read> History }
class Read { Book Book, Date At }
and keeping db schema almost unchanged
User -> UserHistory (UserId, BookId, At) -> Book
I want to map Read
to UserHistory
, the questions are:
- What should I use as
id
in mapping ofRead
?UserHistory
primary key is(UserId, BookId)
. Do I need anid
for NH to work? UserHistory -> Book
seems to be a case ofone-to-one
. How to specify theBookId
column name inUserHistory
in this case? I do not see a column attribute onone-to-one
(and there is a reason for me to be explicit about column name).