INSERT 语句与 FOREIGN KEY 约束“FK_dbo.UserProfile_dbo.UserWork_UserWorkId”冲突。冲突发生在数据库“aspnet-UserAndWork-20130222085848”、表“dbo.UserWork”、列“UserWorkId”中。该语句已终止。
我在加载页面时遇到错误消息这是我的两个表类
public class UserProfile
{
[Key]
public int UserId{get;set;}
public string Username{get;set;}
public int UserWorkId{get;set;}
[foreignkey("UserWorkId")]
public virtual UserWork UserWorkLog{get;set;}
}
public class UserWork
{
[Key]
public int UserWorkId{get;set;}
public int UserId;
//somemoire
}