private void buttonAdd_Click(object sender, EventArgs e) { b = new Books(); AddForm f = new AddForm(b); if (f.ShowDialog() == DialogResult.OK) { Books tmp = bd.Books.Where(x => x.Id_Theme == b.Id_Theme && x.Id_Author == b.Id_Author && x.Id_Publisher == b.Id_Publisher && x.NameBook == b.NameBook && x.Pages == b.Pages && x.Year == b.Year && x.ProductPrice == b.ProductPrice).FirstOrDefault(); if (tmp == null) { bd.Books.Add(b); bd.SaveChanges(); } } }