public static void Initial(CarDbContext context) { if (!context.Categories.Any()) { context.Categories.AddRange(Categories.Select(c => c.Value)); } if (!context.Cars.Any()) { context.AddRange( new Car { CarName = "BMW", CarModel = "M5", YearOfIssue = 2000, CarCost = 800, Category = Categories["Седан"] }, new Car { CarName = "BMW", CarModel = "M4", YearOfIssue = 2001, CarCost = 700, Category = Categories["Купе"] }, new Car { CarName = "BMW", CarModel = "M3", YearOfIssue = 2002, CarCost = 400, Category = Categories["Купе"] } );;;; } context.SaveChanges(); }