【发布时间】:2020-05-13 01:01:49
【问题描述】:
因此,我目前正在尝试为我们的开发人员使用测试信息为开发数据库播种,但我遇到了这个问题 -
实体类型“UserProfile”和“ProjectProgress”之间的关联已被切断,但该关系要么被标记为“必需”,要么被隐含地要求,因为外键不可为空。如果在切断所需关系时应删除依赖/子实体,则设置关系以使用级联删除。考虑使用“DbContextOptionsBuilder.EnableSensitiveDataLogging”来查看键值。
用户配置文件模型 -
public int UserProfileId { get; set; }
public UserProfileStatus UserProfileStatusId { get; set; } = UserProfileStatus.Active;
public SiteRole SiteRoleId { get; set; }
[MaxLength(100)]
public string Username { get; set; }
[MaxLength(50)]
public string Password { get; set; }
[MaxLength(100)]
public string FirstName { get; set; }
[MaxLength(100)]
public string LastName { get; set; }
[MaxLength(20)]
public string Phone { get; set; }
[MaxLength(150)]
public string Email { get; set; }
public DateTime PasswordChangeDt { get; set; } = DateTime.UtcNow;
public DateTime? LastLoginDt { get; set; }
public int InvalidLogins { get; set; }
public bool Locked { get; set; }
public DateTime? LockoutEnd { get; set; } //local copy of auth db value
public bool Analyst { get; set; }
public bool Reviewer { get; set; }
public bool Broker { get; set; }
public bool EmailGlobalStatusAlerts { get; set; }
public bool EmailReviewerStatusAlerts { get; set; }
public bool EmailAssignedStatusAlerts { get; set; }
public bool Active { get; set; }
public int? BankId { get; set; }
public int AddBy { get; set; }
public DateTime AddDt { get; set; } = DateTime.UtcNow;
public int ModBy { get; set; }
public DateTime ModDt { get; set; } = DateTime.UtcNow;
public virtual Bank Bank { get; set; }
[InverseProperty(nameof(ReviewerAnalyst.Analyst))]
public virtual ICollection<ReviewerAnalyst> AnalystReviewers { get; set; } = new
List<ReviewerAnalyst>();
[InverseProperty(nameof(DocumentAccessLog.AccessUser))]
public virtual ICollection<DocumentAccessLog> DocumentAccessLogs { get; set; } = new
List<DocumentAccessLog>();
public virtual ICollection<EmailLog> EmailLogs { get; set; } = new List<EmailLog>();
public virtual ICollection<Note> Notes { get; set; } = new List<Note>();
[InverseProperty(nameof(Project.Analyst))]
public virtual ICollection<Project> ProjectAnalyst { get; set; } = new List<Project>();
[InverseProperty(nameof(Project.Reviewer))]
public virtual ICollection<Project> ProjectReviewer { get; set; } = new List<Project>();
[InverseProperty(nameof(ReviewerAnalyst.Reviewer))]
public virtual ICollection<ReviewerAnalyst> ReviewerAnalysts { get; set; } = new
List<ReviewerAnalyst>();
public virtual ICollection<TimeOff> TimeOffs { get; set; } = new List<TimeOff>();
[InverseProperty(nameof(TimeOff.Approver))]
public virtual ICollection<TimeOff> TimeOffApprovals { get; set; } = new List<TimeOff>();
public virtual ICollection<UserEmailType> UserEmailTypes { get; set; } = new
List<UserEmailType>();
public virtual ICollection<UserRole> UserRoles { get; set; } = new List<UserRole>();
项目进度模型 -
public int ProjectProgressId { get; set; }
public int ProjectId { get; set; }
public int ProgressId { get; set; }
[MaxLength(250)]
public string Notes { get; set; }
public bool Complete { get; set; }
public int AddBy { get; set; }
public System.DateTime AddDt { get; set; }
public virtual Project Project { get; set; }
public virtual Progress Progress { get; set; }
[ForeignKey("AddBy")]
public virtual UserProfile UserProfile { get; set; }
我不知道是否需要帮助解决此问题,但请告诉我,我会更新问题。
【问题讨论】:
标签: c# sql entity-framework entity-framework-core ef-core-3.0