DbSet<TEntity>.AddRangeAsync Method

Definition

Overloads

AddRangeAsync(TEntity[])

Begins tracking the given entities, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

AddRangeAsync(IEnumerable<TEntity>, CancellationToken)

Begins tracking the given entities, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

AddRangeAsync(TEntity[])

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

Begins tracking the given entities, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

public virtual System.Threading.Tasks.Task AddRangeAsync (params TEntity[] entities);

Parameters

entities
TEntity[]

The entities to add.

Returns

A task that represents the asynchronous operation.

Remarks

This method is async only to allow special value generators, such as the one used by 'Microsoft.EntityFrameworkCore.Metadata.SqlServerValueGenerationStrategy.SequenceHiLo', to access the database asynchronously. For all other cases the non async method should be used.

See EF Core change tracking and Using AddRange, UpdateRange, AttachRange, and RemoveRange for more information and examples.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

AddRangeAsync(IEnumerable<TEntity>, CancellationToken)

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

Begins tracking the given entities, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

public virtual System.Threading.Tasks.Task AddRangeAsync (System.Collections.Generic.IEnumerable<TEntity> entities, System.Threading.CancellationToken cancellationToken = default);

Parameters

entities
IEnumerable<TEntity>

The entities to add.

cancellationToken
CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

A task that represents the asynchronous operation.

Exceptions

Remarks

This method is async only to allow special value generators, such as the one used by 'Microsoft.EntityFrameworkCore.Metadata.SqlServerValueGenerationStrategy.SequenceHiLo', to access the database asynchronously. For all other cases the non async method should be used.

See EF Core change tracking and Using AddRange, UpdateRange, AttachRange, and RemoveRange for more information and examples.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0