Web API DAL entities (OnModelCreating)

hello, I need help with object modeling using my created ERD
6 Replies
Thang CHO BOC
Thang CHO BOC2w ago
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?
Omnissiah
Omnissiah2w ago
by back relation you mean navigation property?
Thang CHO BOC
Thang CHO BOC2w ago
yes
Thang CHO BOC
Thang CHO BOC2w ago
No description
Thang CHO BOC
Thang CHO BOC2w ago
No description
Thang CHO BOC
Thang CHO BOC2w ago
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; }?
Want results from more Discord servers?
Add your server