다른 테이블 RFM_NOTD_NotificationsDetail
에 대한 참조가있는 RFM_NOTF_Notifications
이라는 테이블이 있습니다. EF를 사용하여 데이터베이스와 통신하고 NotificationsDetail
엔티티의 목록은 Notifications
입니다. 내가 Notifications
개체의 목록을 업데이트하려고엔티티/모델 업데이트 중 EF 오류 : FOREIGN KEY 제약 조건과 충돌하는 UPDATE 문
,이 오류 받고 있어요 :
The UPDATE statement conflicted with the FOREIGN KEY constraint "FK_RFM_NOTF_Notifications_RFM_NOTD_NotificationsDetail". The conflict occurred in database "RegulatoryFileManagementScrumQA", table "dbo.RFM_NOTD_NotificationsDetail", column 'RFM_NOTD_P_NotificationDetailID'
을 그리고 이것은 저장소 안에 추가/업데이트 방법 :
private void CreateNotifications(GeneralBO file, RFM_NOTD_NotificationsDetail notfFile)
{
foreach (NotificationsBO notf in file.Notifications)
{
RFM_NOTF_Notifications nt = new RFM_NOTF_Notifications
{
RFM_NOTF_B_Description = notf.Description
};
if(notf.Id > 0) // Save
{
nt.RFM_NOTF_P_NotificationID = notf.Id;
nt.RFM_NOTD_F_NotificationDetailID = file.Id;
nt.RFM_NOTF_M_ModifiedById = file.CreatedById;
nt.RFM_NOTF_M_ModifiedDateTime = DateTime.Now;
new GenericRepository<RFM_NOTF_Notifications>(_dbContext).update(nt);
}
else
{
nt.RFM_NOTF_M_CreatedById = file.CreatedById;
nt.RFM_NOTF_M_CreatedDateTime = DateTime.Now;
notfFile.RFM_NOTF_Notifications.Add(nt);
}
}
}
GeneralBO
가있다 UI에서 데이터를 보유하는 모델/객체.
는 그리고이 비즈니스 오브젝트/모델에게
public class NotificationsBO
{
public long Id { get; set; }
public string Description { get; set; }
public int CreatedById { get; set; }
public DateTime CreatedDateTime { get; set; }
public int ModifiedById { get; set; }
public DateTime ModifiedDateTime { get; set; }
}
public class NotificationDetailsBO : ApplicationBO
{
public long Id { get; set; }
.......
.......
public List<NotificationsBO> Notifications { get; set; }
}
입니다 그리고 내 테이블은 다음과 같습니다
감사합니다. – Sandy