change-tracking

Is it possible to enable relationship fixup when change tracking is disabled but proxies are generated

纵饮孤独 提交于 2019-12-10 17:56:41
问题 I have entities which form a tree relationships. class MyEntity { public int Id {get;set;} public int ParentId {get;set;} public virtual MyEntity Parent {get;set;} public virtual ICollection<MyEntity> Children {get;set;} } When these entities are called without AsNoTracking() relationships are fixed up. var entities = MyEntitiesSet.ToList(); All navigation properties and collections are set. However if AsNoTracking() is called: var entities = MyEntitiesSet.AsNoTracking.ToList(); no navigation

How do I turn off change tracking at the DbContext level in EF 4.1 RC?

柔情痞子 提交于 2019-12-09 17:56:30
问题 I've encountered what seems to be a common problem: I am updating values in my database, but EF is using its original in-memory copy of the object and these changed values are not reflected in the displayed data. I understand why this is, but I can't figure out a way around it. The most common solution seems to be to set MergeOptions.NoTracking to turn off change tracking completely (or use the AsNoTracking() extension method when querying) and force a refresh every time the object is

How to implement “get latests changed items” with ADO.NET Data Services?

为君一笑 提交于 2019-12-08 11:59:05
问题 Lets say I have a lists of entities (for example, a list of TODO items) that more than one user can change, delete from and add to at the same time. So to maintane a synchronized listed between all the clients, I want each client (AJAX based) to ask for changes every xx seconds. Since the list can get veeery long, I do not want to do a full request each time, but only ask for the changed items (items can be updated, deleted or new). Is it possible with ADO.NET Data Services? If so, how do I

Enable change tracking on all tables in database

时光毁灭记忆、已成空白 提交于 2019-12-07 09:42:40
问题 Assuming change tracking is enabled on a SQL Server database, how do I enable change tracking on all the tables in the database? 回答1: You could use following T-SQL script to generate another T-SQL script which enable CHANGE TRACKING feature on all tables with primary keys: -- Step #1: Execute below script having [Results to text] option selected (Ctrl + T) SET NOCOUNT ON; GO -- Is CHANGE TRACKING enabled at database level ? IF CONVERT(INT, PARSENAME(CONVERT(NVARCHAR(128), SERVERPROPERTY(

Entity Framework Change Tracking API and reference entries

非 Y 不嫁゛ 提交于 2019-12-07 01:36:55
问题 Looking to write generic Audit code on my DbContext subclass. foreach (var entry in this.ChangeTracker.Entries<MyClass>()) { if (entry.State == EntityState.Modified) { var entityProperties = entry.Entity.GetType().GetProperties(); foreach (var entityProperty in entityProperties) { DbMemberEntry propertyEntry = entry.Member(property.Name); if (propertyEntry is DbPropertyEntry) { // IsModified available } else if (propertyEntry is DbReferenceEntry) { // IsModified not available } } } } 1) If I

Entitity Framework: Change tracking in SOA with POCO approach

我是研究僧i 提交于 2019-12-07 00:26:45
问题 In our layered application, we are accessing database via WCF calls. We are creating and disposing contexts per request. Also we are using POCO approach. My question is, in pure POCO model (completely persistent ignorant POCOs) is it possible to track the changes, while we are creating and disposing context per request (as previous context is disposed in that service call)? If yes how EF handles this situation? As far as I can see 2 mechanisms (snapshot based change tracking and notification

MySQL database change tracking

落花浮王杯 提交于 2019-12-06 03:50:44
What tools are you using to track changes in your MySQL database? Currently I'm in a project where we use a plain text-file (version controlled via SVN) in which we manually add SQL statements when making changes to the database. Many of the changes magically disappears every now and then, and we are now looking for a better way to change track our database. EDIT: One thing that I forgot to mention, we are using stored procedures and functions, so it's not only the database structure that we want to track changes on / version controll. There is a simple solution: Make all changes to the

Entity Framework Change Tracking API and reference entries

感情迁移 提交于 2019-12-05 04:34:57
Looking to write generic Audit code on my DbContext subclass. foreach (var entry in this.ChangeTracker.Entries<MyClass>()) { if (entry.State == EntityState.Modified) { var entityProperties = entry.Entity.GetType().GetProperties(); foreach (var entityProperty in entityProperties) { DbMemberEntry propertyEntry = entry.Member(property.Name); if (propertyEntry is DbPropertyEntry) { // IsModified available } else if (propertyEntry is DbReferenceEntry) { // IsModified not available } } } } 1) If I only change a reference property, the entry.State value is "Unchanged". 2) Even if point 1 was set to

How do I turn off change tracking at the DbContext level in EF 4.1 RC?

爷,独闯天下 提交于 2019-12-04 04:07:18
I've encountered what seems to be a common problem: I am updating values in my database, but EF is using its original in-memory copy of the object and these changed values are not reflected in the displayed data. I understand why this is, but I can't figure out a way around it. The most common solution seems to be to set MergeOptions.NoTracking to turn off change tracking completely (or use the AsNoTracking() extension method when querying) and force a refresh every time the object is accessed, which is fine for my purposes. I've got a generic base repository which my other repositories

EF 4.1 Code First - Determine What Properties Have Changed

牧云@^-^@ 提交于 2019-12-03 03:53:04
问题 I'm using Entity Framework 4.1 Code First. Is there a built-in way to get a list of what properties have changed since the entity was loaded from the database? I know code first detects that an object was changed, but is there a way to get exactly what properties have changed? 回答1: For scalar and complex properties you can use the following to extract the changed property names of an entity myEntity : var entry = context.Entry(myEntity); var namesOfChangedProperties = entry.CurrentValues