Take the 2-minute tour ×

I have a database context with multiple database set. I have an edit (httpget) and an edit (httppost) method. I want to save specific data in specific datasets. How can I specify which database set I want to use? BTW, the view from of the Edit method uses several models.

My database context looks like this:

public class mycontext :DBContext
  public DBSet<Table1> table1{get; set;}
  public DBSet<Table2> table2{get; set;}
  public DBSet<Table3> table3{get; set;}

When I define

private mycontext data = new mycontext()

The only option is data.SaveChanges(). I want to so something like data.table1.SaveChanges() and pass in the data I want to save.

share|improve this question
The whole point of the DbContext in Entity Framework is that it keep track of the changes itself, and saves out whatever is needed, all in one transaction, when you call .SaveChanges() on it. You cannot just save half the changes, on one table - all the changes you've made to the context will be saved - all at once –  marc_s Dec 21 '12 at 16:42
Thanks. But say I have a field whose value depend on the button clicked to submit the form and I need to update that field in the table. How will I do that please? –  jpo Dec 21 '12 at 18:51
add comment

1 Answer

if you only want to update data in Table1, modify only data in Table1, and then call .SaveChanges()

share|improve this answer
add comment

Your Answer


