I am learning how to work with C # databases. Created a local database Clients
with two tables Companies
and Users
. (clients are companies that, in turn, have users, but this is not the point). Generated an entity model for the Clients
database (EDM). When you try to add a record to a table, difficulties arise: the code works without errors, but there are no changes in the database itself. What am I doing wrong?
void Test() { ClientsEntities context1 = new ClientsEntities(); try { context1.Companies.Add( new Companies {CompanyID = 1, ContractStatus = 2, CompanyName = "ggg"}); MessageBox.Show("Успешно"); } catch { MessageBox.Show("fail"); } context1.SaveChanges(); }
connectionString
to the question. How do you verify that "no change is observed"? - Dmitry