Questions tagged [savechanges]

DbContext.SaveChanges method in an Entity Framework method that saves all changes made in a context to the underlying database.

DbContext.SaveChanges method is Entity Framework method that saves all changes made in a context to the underlying database. More info: https://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext.savechanges%28v=vs.113%29.aspx

421 questions
0
votes
2 answers

DbContext.SaveChanges Fails to Save Valid Entities

I'm using EF 5 with Code First POCO. Here is the repository's SaveChanges implementation: public virtual List SaveChanges() { var errors = new List(); try { …
rkralston
  • 386
  • 1
  • 5
  • 20
0
votes
1 answer

Unable to grab related parent entity object & add it to the ObjectContext

I am currently having difficulty tracking and adding a parent-entity object to my context after successfully adding its related child. I have two SQL tables mapped to my entities that are related by a foreign key: MasterPartNumber (parent, one) -->…
0
votes
1 answer

Updating one-to-many relationships without SaveChanges

When a call is made to the SaveChanges() method of an context, the relationships on the other side of the change are automatically updated. For instance if I had a teacher mrX with a virtual ICollection of students including…
Brent
  • 4,611
  • 4
  • 38
  • 55
0
votes
1 answer

db.SaveChange(); Exception - value connot be null

In WPF application I want save data to databese. db.Pytanias.Add(pyt); //all parameters in pyt has a value db.SaveChanges(); When is saving to database I get an exception: System.ArgumentNullException was unhandled HResult=-2147467261 …
user1031034
  • 836
  • 1
  • 14
  • 38
0
votes
3 answers

How to save a server generated complex object tree with entities that are not yet exsisting in the database?

In my spa I need to send a complex object tree to the client and let the user fill in his data, before the entities can be saved in the database. So the entities do not exist in the database at that moment. The object tree is constructed in memory…
AndyK
  • 117
  • 1
  • 7
0
votes
2 answers

Entity framework - adding new object

I've entity type called 'Question', when i create new instance of it and add it to entity set 'Questions' (using AddObject()), than call SaveChanges() method on context, all works fine. But when i added it, but not call SaveChanges() yet and try to…
igorGIS
  • 1,888
  • 4
  • 27
  • 41
0
votes
1 answer

Entity Framework SaveChanges(False) fails while using TransactionScope

The question asked on following link has a great answer under that as well but my problem starts after that. Using Transactions or SaveChanges(false) and AcceptAllChanges()? I tried the code given as per my requirement as follows MyEntities…
Manish
  • 47
  • 5
0
votes
1 answer

DbContext.SaveChanges() causing DbUpdateException in loop

I have a process that creates an object that is responsible for inserting into header /detail records. If I run the code to insert into the table on its own, every thing runs fine. However, when I call that code as a separate class within a loop I…
0
votes
0 answers

xcode 4: How to save user changes from more tab bar

Possible Duplicate: How to: Save order of tabs when customizing tabs in UITabBarController I want to make it so that when on a tab bar application, if someone changes the order of the bottom tabs(e.g. move one from the 'more' section to the main…
PolygonHJ
  • 82
  • 1
  • 2
  • 13
0
votes
2 answers

Linq SaveChanges question

Should I bother doing this check to see if the object(s) saved correctly? if (objectContext.SaveChanges() > 0) It should just throw an exception if it didn't, right?
Alex
  • 129
  • 2
  • 10
0
votes
1 answer

How to detect if an Entity added to DbContext?

Possible Duplicate: DBContext Added/Attached Event? I'm using a custom ID-Generating strategy in EF 5. I override the SaveChanges method to detect added entities and set them IDs. But the new entities's ID is not accessible until calling…
0
votes
1 answer

Saving changes from yield return via Entity Framework

I am facing a problem getting Entity Framework to save results from yield return properly. To illustrate the problem I created 2 sets of methods, one returns an entity and the other returns an IEnumerable using yield return. Journal references…
0
votes
1 answer

How do i save options changed by user interaction?

I've asked a question like this before but the answers did not really help. If the user has changed the settings how do i save it so when the application is killed the changes are still saved. I have tried to use and save an int when the setting is…
dizazta
  • 77
  • 2
  • 11
0
votes
2 answers

how to save changes in wpf events lines

the problem is the wpf not save changes Only after the end of the event //code private void button1_Click(object sender, RoutedEventArgs e) { for (int ii = 0; ii <= 5; ii++) { Rectangle rectr = (Rectangle)FindName("rect" + ii); …
Ahmed Samir
  • 53
  • 10
0
votes
1 answer

How to update Db from passed in entity object

I have a list of OrderDetail records that I have added, updated and deleted items from. I need to be able to pass this entity object to another layer for saving changes. How can I do this? Do I need to detach the list from it's current Context…
Jerry
  • 6,357
  • 8
  • 35
  • 50