Share via


DbSet<TEntity>.Local Property

Definition

Gets a LocalView<TEntity> that represents a local view of all Added, Unchanged, and Modified entities in this set.

public virtual Microsoft.EntityFrameworkCore.ChangeTracking.LocalView<TEntity> Local { get; }
member this.Local : Microsoft.EntityFrameworkCore.ChangeTracking.LocalView<'Entity (requires 'Entity : null)>
Public Overridable ReadOnly Property Local As LocalView(Of TEntity)

Property Value

Remarks

This local view will stay in sync as entities are added or removed from the context. Likewise, entities added to or removed from the local view will automatically be added to or removed from the context.

This property can be used for data binding by populating the set with data, for example by using the Load<TSource>(IQueryable<TSource>) extension method, and then binding to the local data through this property by calling ToObservableCollection() for WPF binding, or ToBindingList() for WinForms.

Note that this method calls DetectChanges() unless AutoDetectChangesEnabled has been set to false.

See Local views of tracked entities in EF Core for more information and examples.

Applies to