Note

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

Access to this page requires authorization. You can try .

DbSet<TEntity>.Find(Object[]) Method

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.

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the database for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found, then null is returned.

public virtual TEntity Find(params object[] keyValues);
public virtual TEntity? Find(params object?[]? keyValues);
abstract member Find : obj[] -> 'Entity
override this.Find : obj[] -> 'Entity
Public Overridable Function Find (ParamArray keyValues As Object()) As TEntity

Parameters

keyValues
Object[]

The values of the primary key for the entity to be found.

Returns

TEntity

The entity found, or null.

Remarks

See Using Find and FindAsync for more information and examples.

Applies to


Feedback

Was this page helpful?