
[EFCore] Pricipal 데이터가 없을 때 Dpendent 데이터가 존재할 수 있는가?
·
공부/EFCore
Pricipal 데이터가 없을 때 Dpendent 데이터가 존재할 수 있는가? ✅ Nullable 유무에 따라 다르다. 1️⃣ OwnerId가 Nullable로 설정되지 않았을 때 OwnerId 하나를 삭제하면, public class Item { public int ItemId { get; set; } public int TemplateId { get; set; } public DateTime CreateDate { get; set; } public int OwnerId { get; set; } public Player Owner { get; set; } } Test를 통해 PlayerId가 1인 Owner 정보를 삭제하자 Owner 뿐만 아니라 Item 정보도 모두 사라졌다. 2️⃣ OwnerId가 ..