The problem is "An author may have none or many books, but a book is never written by two or more authors."
public Author(Document cpf, string name, DateTime birthdate)
{
Cpf = cpf;
Name = name;
Birthdate = birthdate;
}
public Document Cpf { get; private set; }
public string Name { get; private set; }
public DateTime Birthdate { get; private set; }
// EF Relation
public Book Book { get; private set; }
public ICollection<Book> Books { get; private set; }
protected Author() { }
// 0 : N => Author : Books
builder.HasMany(c => c.Books)
.WithOne(b => b.Author)
.HasForeignKey(b => b.AuthorId);
public Book(Guid categoryId, Guid authorId, string title, DateTime releaseDate, BookIdentificator isbn)
{
CategoryId = categoryId;
AuthorId = authorId;
Title = title;
ReleaseDate = releaseDate;
Isbn = isbn;
}
public Guid CategoryId { get; private set; }
public Guid AuthorId { get; private set; }
public string Title { get; private set; }
public DateTime ReleaseDate { get; private set; }
public BookIdentificator Isbn { get; private set; }
public Category Category { get; private set; }
public Author Author { get; private set; }
// 1 : 1 => Books : Author
builder.HasOne(c => c.Author)
.WithOne(b => b.Book)
.HasForeignKey(b => b.AuthorId);
Error: Cannot convert lambda expression to type 'string' because it is not a delegate type BookManager.Catalog.Data