The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

vbali (1) [Avatar] Offline
#1
Hi

Can anyone help me with creating class definition for BookAuthor class used in chapter 7 page 244?

I keep on getting following error message: "Invalid association mapping for member 'Author.BookAuthors'. 'BookAuthor' is not an entity."

Here is my code for BookAuthor and Author class

[Table(Name="dbo.BookAuthor")]
class BookAuthor
{
[Column(Name="Author")]
public Guid Author { get; set; }

[Column(Name="Book")]
public Guid Book { get; set; }

[Column(Name="AuthorOrder")]
public int? AuthorOrder { get; set; }
}

[Table(Name="dbo.Author")]
class Author
{
[Column(Storage = "iD", Name = "ID", DbType = "UniqueIdentifier NOT NULL", IsPrimaryKey = true, CanBeNull = false)]
private Guid iD;

public Guid ID
{
get { return iD; }
set { iD = value; }
}

[Column(Name="FirstName", DbType="varchar(30) not null", CanBeNull=false, UpdateCheck=UpdateCheck.Never)]
public string FirstName { get; set; }

[Column(Name="LastName", DbType="varchar(30) not null", CanBeNull = false, UpdateCheck=UpdateCheck.Never)]
public string LastName { get; set; }

[Column(Name="WebSite", DbType="varchar(200)", UpdateCheck=UpdateCheck.Never)]
public string WebSite { get; set; }

[Column(Name = "IsUpdated", DbType = "RowVersion not null", IsDbGenerated = true, IsVersion = true, CanBeNull = false,
UpdateCheck = UpdateCheck.Always)]
public byte[] RowVersion { get; set; }


private EntitySet<BookAuthor> _BookAuthors = null;

[Association(Name = "FK_BookAuthor_Author", Storage = "_BookAuthors", OtherKey = "Author", ThisKey = "ID")]
public EntitySet<BookAuthor> BookAuthors
{
get
{
return this._BookAuthors;
}
set
{
this._BookAuthors.Assign(value);
}
}

Thanks