I have two models that looks like this:
[Table("Titles")]
public partial class Title
{
[Key]
[Column("TitleId")]
public virtual string Genre { get; set; }
[ForeignKey("Genre")] // I want to link using the Genre field
public virtual Genre GenreInfo { get; set; }
}
[Table("Genres")]
public partial class Genre
{
[Key]
[Column("GenreID")]
public int GenreID { get; set; } *** This is the actual PK in the table
public string Genre { get; set; } // This contains unique genre code.
public string Keywords { get; set; }
}
The foreignKey in the title table is the field "Genre" not the GenreId. How do I define the relationship in the Title model that loads the genre infor using the Genre field?
It is a many to one relationship. (Titles can have only one genre)