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(); } 
  • one
    And where does the WPF to your question? - VladD
  • Well, yes, probably not quite in the topic (and so, I create a WPF application) - Nikita
  • Then let's remove the extra code from the question. - VladD
  • Add a connectionString to the question. How do you verify that "no change is observed"? - Dmitry
  • After starting the program and pressing the button (Messagebox success appears), I open the database, there is nothing in it except the column names. - Nikita

0