public void CarInsert([FromBody] CarViewModel car) { if (!ModelState.IsValid) { throw new Exception("Invalid error"); } var c = car.ToEntity(); var vehicle = car.ToVehicleEntity(); vehicle.Car = c; dbContext.Vehicle.Add(vehicle); dbContext.SaveChanges(); }