1
코드를 사용하여 EF를 배우려고하는데,이 방법을 사용하여 올바르게 디자인하는 법을 모릅니다. 나에게EF 코드 첫 번째 테이블 관계
내 수업을 도와주세요 것은 내가 외래 키가되도록 StockUnitOfMeasure
및 PurchaseUnitOfMeasure
을 갖고 싶어이
public class Item
{
public int ItemID{ get; set; }
public string Name { get; set; }
public int StockUnitOfMeasure{ get; set; }
public int PurchaseUnitOfMeasure{ get; set; }
}
public class UnitOfMeasure
{
public int UnitOfMeasureID { get; set; }
public string MeasureName { get; set; }
}
것 같습니다.
는 여기에서 그는 샘플 데이터 내가 Id
으로 FK 속성을 접미사로 한 선명도와 컨벤션
ItemID Name StockUnitOfMeasure PurchaseUnitOfMeasure
1 Apples 2 1
2 Milk 3 4
UnitOfMeasureID MeasureName
1 Piece
2 Dozen
3 Box
4 Packs
meaning:
apples are stocked at the warehouse by DOZEN, but will be purchased per PIECE
Milks are stocked at the warehouse by BOX, but will be purchased per PACK
많은 감사
그러나 나는이 오류 {는 "참조 관계는 허용되지 않는 순환 참조가 발생합니다. [제약 조건 이름 = Item_PurchaseUnitOfMeasure]"} – samantha07@ samantha07은'.WillCascadeOnDelete를 설정 발생 (true)'를 .WillCascadeOnDelete (false)'로 설정하십시오. – Eranga