Answer the question
In order to leave comments, you need to log in
I added a new field to the table but I can't change its value, what should I do?
Good day!
I have the following situation: I
have an application for working with a database (and the application and the database are not mine, so I don’t understand their structure yet), I need to add a new field to one of the tables, add it through SQL Management studio, then open the project, go into the database model (file with the .edmx extension) right-clicked on an empty space and clicked the "Update model from the database" button.
I selected the table I needed in the "Update" tab and clicked the "Finish" button.
After I tried to read the data of this field from all records as follows:
using (TestContext db = new TestContext ())
{
var ps = db.Project_test.ToList();
foreach (Project_test p in ps)
{
MessageBox.Show(p.TypeContract);
}
}
using (TestContext db = new TestContext ())
{
var ps = db.Project_test.ToList();
foreach (Project_test p in ps)
{
p.TypeContract = "test_value";
}
db.SaveChanges();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question