You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have thought that result set of the SQL statement is hold on the memory.
Updating with ExecuteSqlCommand
If you use this method, you can freely run the SQL statement. However, SQL statements can be executed regardless of the contents of the entity. Therefore, I think that contents of the entity and database do not match after execution of this method.
If it is the behavior as described above, there is a need to refresh the contents of the entities?
For matter of "* 1", when you look at the code of the Entity Framework from the following URL, each time entry.AcceptChanges method is executed against a record of change in a foreach in the AcceptAllChanges method.
For this reason, Entity Framework so that is doing the update instruction from the program for each of changed records. Round-trip between the APServer and DBServer occurs in such a processing method. Therefore, I think about the performance of problem occurs in the batch processing of large amounts of data processing.
Since the connection / transaction is created every time you call the SaveChanges method, Following (a) and (b) to use a different connection / another transaction. If you want to explicitly manage transactions, it is written the way to "treat as a single transaction(1つのトランザクションとして扱う)" in the above-referenced site.
Correct the Entity call the SaveChanges method (a)
Correct the Entity call the SaveChanges method (b)
For this reason, I think that it may dispense with as much as possible a single call to SaveChanges method. However, in the following case I think that there is a need to manage the explicit connection / transaction.
If you need to call more than once SaveChanges method.
When used in combination the SaveChanges method and ExecuteSqlCommand methods.
When used in combination the SaveChanges method and stored procedures.
There is something like a Better use in Entity Data Model how to make?
For example, either "divide the Entity Data Model in arbitrary units" or "entities combine into a single Entity Data Model".
If you wrap the Entity to one of the Entity Data Model, it is easy to combine multiple entity update to the call of a single SaveChanges method.
If you divide the Entity multiple of Entity Data Model, there is a need to call multiple times SaveChanges method. Therefore connection / transaction explicit management is required.
The text was updated successfully, but these errors were encountered:
Questions about EntityFramework
We have a variety of questions about EntityFramework.
We will request an investigation of the following questions to you.
Memory usage
We believe that EntityFramework behave as follows.
Updating with ExecuteSqlCommand
http://stackoverflow.com/questions/18169970/how-do-i-refresh-dbcontext
Connection / Transaction management of SaveChanges method
http://ichiroku11.hatenablog.jp/entry/2014/04/16/232004
http://entityframework.codeplex.com/SourceControl/latest#src/EntityFramework/Core/Objects/ObjectContext.cs
There is something like a Better use in Entity Data Model how to make?
For example, either "divide the Entity Data Model in arbitrary units" or "entities combine into a single Entity Data Model".
The text was updated successfully, but these errors were encountered: