private void CreateContactDetail(ShopOnlineDbContext context) { if (context.ContactDetails.Count() == 0) { try { var contactDetail = new ShopOnline.Model.Models.ContactDetail() { Name = "Shop thời trang online", Address = "k34 Lê Văn Thứ", Email = "*****@*****.**", Lat = 21.0633645, Lng = 105.8053274, Phone = "0905629025", Website = "", Other = "", Status = true }; context.ContactDetails.Add(contactDetail); context.SaveChanges(); } catch (DbEntityValidationException ex) { foreach (var eve in ex.EntityValidationErrors) { Trace.WriteLine($"Entity of type \"{eve.Entry.Entity.GetType().Name}\" in state \"{eve.Entry.State}\" has the following validation error."); foreach (var ve in eve.ValidationErrors) { Trace.WriteLine($"- Property: \"{ve.PropertyName}\", Error: \"{ve.ErrorMessage}\""); } } } } }
private void CreateContactDetail(ShopOnlineDbContext context) { if (context.ContactDetails.Count() == 0) { try { var contactDetail = new ShopOnline.Model.Models.ContactDetail() { Name = "Cửa hàng điện lạnh Xuân Hoàng", Address = "Ngõ 56 Cổ Nhuế", Email = "*****@*****.**", Lat = 21.0657715, Lng = 105.7765664, Phone = "0968207096", Website = "http://google.com.vn", Other = "", Status = true }; context.ContactDetails.Add(contactDetail); context.SaveChanges(); } catch (DbEntityValidationException ex) { foreach (var eve in ex.EntityValidationErrors) { Trace.WriteLine($"Entity of type \"{eve.Entry.Entity.GetType().Name}\" in state \"{eve.Entry.State}\" has the following validation error."); foreach (var ve in eve.ValidationErrors) { Trace.WriteLine($"- Property: \"{ve.PropertyName}\", Error: \"{ve.ErrorMessage}\""); } } } } }