I've created a simple Form containing two TextBoxes for name and age, and a button to submit. I added a "Local Database" to my project called Sample.sdf.
I've created a table called Customers and added three columns: Id, Name, and Age.
I've set the Id column as the primary key but didn't set it as an identity column.
Then, I added an "ADO.NET Entity Data Model" called SampleEntities. I selected "Generate from database" and chose the Sample.sdf. I've selected the table and clicked Finish.
In my Button_Click event I've done:
using (SampleEntities se = new SampleEntities())
{
Customer c = new Customer();
c.Id = FindNextId();
c.Age = Convert.ToDouble(txtAge.Text);
c.Name = txtAge.Text;
se.AddToCustomers(c);
se.AcceptAllChanges();
se.SaveChanges();
}
MessageBox.Show("Done");
I'm getting the "Done" message with no problems, but the records are not showing in the Server Explorer - Customers table - Show Table Data option.
Note: I know that in runtime, the sdf file is located in my debug folder. I'm checking both the sdf file in the project directory, and the sdf file in the debug folder, and neither have any records. Furthermore, I have set my sdf file property "Copy To Output Directory" to "Copy if newer".
So my question is, where is the customer row?