سلام وقت بخیر
یک نمایشگاه ماشین ایده تمرینی درست کردم
public class Car
{
[Key]
public int Id { get; set; }
[MaxLength(100)]
public string CarName { get; set; }
[MaxLength(100)]
public string CarCompany { get; set; }
public DateTime DateOfManufacture { get; set; }
public DateTime CreateDate { get; set; }
public List<CarInExhibition>? MyProperty { get; set; }
} public class Exhibition
{
[Key]
public int Id { get; set; }
[MaxLength(100)]
public string ExhibitionName { get; set; }
[MaxLength(300)]
public string AddressShop { get; set; }
[MaxLength(50)]
public int? NumberOfCars { get; set; }
[MaxLength(50)]
public string Mobile { get; set; }
public DateTime CreateDate { get; set; }
//Releation
public List<CarInExhibition>? MyProperty { get; set; }
} public class CarInExhibition
{
[Key]
public int Id { get; set; }
public int CarId { get; set; }
public int ExhibitionId { get; set; }
public DateTime RegisterDate { get; set; }
//Releation
[ForeignKey("CarId")]
public Car? Car { get; set; }
[ForeignKey("ExhibitionId")]
public Exhibition? Exhibition { get; set; }
} internal class Car_Db : DbContext
{
#region DbSets
public DbSet<Car> Cars { get; set; }
public DbSet<Exhibition> Exhibitions { get; set; }
public DbSet<CarInExhibition> Inhibitions { get; set; }
#endregion
}
به این رابطه چند به چند هم میگین یا فرق میکنه کلا
بسیار عالی
بله چند به چند هست