Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

DbSet<TEntity>.Local Property

Definition

Namespace:
Microsoft.EntityFrameworkCore
Assembly:
Microsoft.EntityFrameworkCore.dll
Package:
Microsoft.EntityFrameworkCore v1.1.6
Package:
Microsoft.EntityFrameworkCore v10.0.0
Package:
Microsoft.EntityFrameworkCore v2.0.3
Package:
Microsoft.EntityFrameworkCore v2.1.11
Package:
Microsoft.EntityFrameworkCore v2.2.6
Package:
Microsoft.EntityFrameworkCore v3.0.0
Package:
Microsoft.EntityFrameworkCore v3.1.0
Package:
Microsoft.EntityFrameworkCore v5.0.0
Package:
Microsoft.EntityFrameworkCore v6.0.0
Package:
Microsoft.EntityFrameworkCore v7.0.0
Package:
Microsoft.EntityFrameworkCore v8.0.0
Package:
Microsoft.EntityFrameworkCore v9.0.0
Source:
DbSet.cs
Source:
DbSet%60.cs
Source:
DbSet%60.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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


Feedback

Was this page helpful?