public static void AddWeatherRecord(int cityId, Weather weather) { try { WeatherReportModel.Weather w = new WeatherReportModel.Weather(); w.cityId = cityId; w.clothingLayers = weather.clothingLayers; w.issued = weather.issued; w.location = weather.location; w.past = weather.past; w.pressure = weather.pressure; w.rainfall = weather.rainfall; w.relativeHumidity = weather.relativeHumidity; w.status = weather.status; w.temperature = weather.temperature; w.time = weather.time; w.windChill = weather.windChill; w.windDirection = weather.windDirection; w.windGustSpeed = weather.windGustSpeed; w.windProofLayers = weather.windProofLayers; w.windSpeed = weather.windSpeed; w.windSpeedDesc = weather.windSpeedDesc; WeatherReportEntities dbContext = new WeatherReportEntities(); dbContext.Weathers.Add(w); dbContext.SaveChanges(); } catch (DbEntityValidationException e) { //Debug.WriteLine(ex.Message); foreach (var eve in e.EntityValidationErrors) { Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } }