I have two tables that are already created. Documentand DocumentStyle. They have a one-to-one relationship across the column DocumentID. However, it is called Idin the table Documentand DocumentIDin the table DocumentStyle.
Something like that
> Document DocumentStyle
> |----------| |----------------|
> |Id - Key |<------>|DocumentId- key |
> |Name-VChar| |Color -VChar|
> |Desc-VChar| |Font VChar |
> |----------| |----------------|
I get the following error in VS
The ForeignKeyAttribute property of the 'DocumentStyle' property of type Invalid "KII.Models.Document". The foreign key name 'DocumentId' was not found on the dependent type 'KII.Models.Document. The Name value must be separated by a comma-separated list of foreign key property names.
This is part of the code for the Document model class.
[ForeignKey("DocumentId")] public
DocumentStyle DocumentStyle { get;set; }
EDIT:
This is the code of my classes.
public class Document
{
[Key]
public int ID { get; set; }
public string Name { get; set; }
public int FundId { get; set; }
public int ClientId { get; set; }
[ForeignKey("FundId")]
public Fund Fund { get; set; }
[ForeignKey("ClientId")]
public Client Client { get; set; }
[ForeignKey("ID")]
public DocumentStyle DocumentStyle { get; set; }
public Document()
{
}
public Document(DocumentStyle documentStyle)
{
DocumentStyle = documentStyle;
}
}
public class DocumentStyle
{
public DocumentStyle()
{
}
[Key]
[DisplayName("Document ID")]
public int DocumentId { get; set; }
[ForeignKey("DocumentId")]
public Document Document { get; set; }
[DisplayName("Title Foreground Color")]
public string TitleForegroundColor { get; set; }
[DisplayName("Title Background Color")]
public string TitleBackgroundColor { get; set; }
[DisplayName("Title Font Family")]
public string TitleFontFamily { get; set; }
[DisplayName("Title Font Size")]
public string TitleFontSize { get; set; }
[DisplayName("Title Font Style")]
public string TitleFontStyle { get; set; }
[DisplayName("Title Font Weight")]
public string TitleFontWeight { get; set; }
[DisplayName("Title Text Decoration")]
public string TitleTextDecoration { get; set; }
[DisplayName("Section Title Foreground Color")]
public string SectionTitleForegroundColor { get; set; }
[DisplayName("Section Title Background Color")]
public string SectionTitleBackgroundColor { get; set; }
[DisplayName("Section Title Font Family")]
public string SectionTitleFontFamily { get; set; }
[DisplayName("Section Title Font Size")]
public string SectionTitleFontSize { get; set; }
[DisplayName("Section Title Font Styled")]
public string SectionTitleFontStyle { get; set; }
[DisplayName("Section Title Font Weight")]
public string SectionTitleFontWeight { get; set; }
[DisplayName("Section Title Text Decoration")]
public string SectionTitleTextDecoration { get; set; }
[DisplayName("Paragraph Foreground Color")]
public string ParagraphForegroundColor { get; set; }
[DisplayName("Paragraph Background Color")]
public string ParagraphBackgroundColor { get; set; }
[DisplayName("Paragraph Font Family")]
public string ParagraphFontFamily { get; set; }
[DisplayName("Paragraph Font Size")]
public string ParagraphFontSize { get; set; }
[DisplayName("Paragraph Font Style")]
public string ParagraphFontStyle { get; set; }
[DisplayName("Paragraph Font Weight")]
public string ParagraphFontWeight { get; set; }
[DisplayName("Paragraph Text Decoration")]
public string ParagraphTextDecoration { get; set; }
[DisplayName("Logo")]
public byte[] Logo { get; set; }
}