I’m trying to learn EF using code first, i dont know how to design properly using this method. Please help me
My classes looks like this
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; }
}
I want to have the StockUnitOfMeasure and PurchaseUnitOfMeasure to be the foreign key.
Here’s he sample data
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
For clarity and conventions I have suffixed the FK properties with
Id. You can rename these to suite your need.