Monday, 19 August 2013

Code First foreign key error

Code First foreign key error

I have this:
[Table("Providence")] public class Providence { public Providence() {
this.ProvidenceInteraction = new HashSet(); }
public int ProvidenceId { get; set; }
public int DocumentGroupId { get; set; }
[ForeignKey("User")]
public int UserId { get; set; }
public System.DateTime CreationDate { get; set; }
public int ProvidenceStatusId { get; set; }
public virtual DocumentGroup DocumentGroup { get; set; }
public virtual ProvidenceStatus ProvidenceStatus { get; set; }
public virtual User User { get; set; }
public virtual ICollection<ProvidenceInteraction>
ProvidenceInteraction { get; set; }
}
when compiled the aplication the My Context generate this query:
SELECT
[Extent1].[ProvidenceId] AS [ProvidenceId],
[Extent1].[DocumentGroupId] AS [DocumentGroupId],
[Extent1].[UserId] AS [UserId],
[Extent1].[CreationDate] AS [CreationDate],
[Extent1].[ProvidenceStatusId] AS [ProvidenceStatusId],
[Extent1].[User_UserId] AS [User_UserId],
[Extent1].[User_UserId1] AS [User_UserId1]
FROM [dbo].[Providence] AS [Extent1]
Gerating [Extent1].[User_UserId] AS [User_UserId],
[Extent1].[User_UserId1] AS [User_UserId1] MORE if not execute the
context... what is error??

No comments:

Post a Comment