Web API DAL entities (OnModelCreating)

hello, I need help with object modeling using my created ERD
6 Replies
spit on that Thang CHO BOC
If I have to have a "back relation" is modifier as required? (or record or readonly?) example
public class Orders
{
public int Id { get; set; }
public required Offers Offer { get; set; }
public required ApplicationUser User { get; set; }
public string Amount { get; set; }
public required string Price { get; set; }
public string PaymentType { get; set; }
public bool Status { get; set; }
}
public class Orders
{
public int Id { get; set; }
public required Offers Offer { get; set; }
public required ApplicationUser User { get; set; }
public string Amount { get; set; }
public required string Price { get; set; }
public string PaymentType { get; set; }
public bool Status { get; set; }
}
public class Offers
{
public int Id { get; set; }
public required string Name { get; set; }
public required int Price { get; set; }
public required string Currency { get; set; }
public required string Amount { get; set; }
public required string UnitsAvaiable { get; set; }
public required string Origin { get; set; }
public required string OfferType { get; set; } = "Online";
public required ICollection<CropCategories> CropCategory { get; set; }

// Return relations
public ApplicationUser User { get; set; }
public ICollection<Crops> Crop { get; set; }
public ICollection<Orders> Order { get; set; }
}
public class Offers
{
public int Id { get; set; }
public required string Name { get; set; }
public required int Price { get; set; }
public required string Currency { get; set; }
public required string Amount { get; set; }
public required string UnitsAvaiable { get; set; }
public required string Origin { get; set; }
public required string OfferType { get; set; } = "Online";
public required ICollection<CropCategories> CropCategory { get; set; }

// Return relations
public ApplicationUser User { get; set; }
public ICollection<Crops> Crop { get; set; }
public ICollection<Orders> Order { get; set; }
}
for the Orders i dont have to backtrack the relation because i use the ID as the attribute but when I have Offer i have to backtrack to get the OnModelCreating working is that supposed to be correct?
FestivalDelGelato
by back relation you mean navigation property?
spit on that Thang CHO BOC
public class ApplicationUser : IdentityUser
{
public string Role { get; set; }

}
public class ApplicationUser : IdentityUser
{
public string Role { get; set; }

}
so that means I have to add a "return relation" ICollection<Orders> Order {get;set;}? or? public object Offer { get; internal set; }?

Did you find this page helpful?