private void Button_Click(object sender, RoutedEventArgs e) { string NameOfCompany = textbox1.Text; string PhoneNumber = textbox2.Text; Shipper shipper = new Shipper(); var shipper1 = new ShipperViewModel(shipper); shipper1.CompanyName = NameOfCompany; shipper1.Phone = PhoneNumber; textbox1.Text = String.Empty; textbox2.Text = String.Empty; if(shipper1.CompanyName == null || shipper1.CompanyName == "" ) return; MessageBox.Show("You added a shipper"); NORTHWNDEntities1 entities = new NORTHWNDEntities1(); entities.Shippers.Add(shipper); entities.SaveChanges(); }