DbSet<TEntity>.AddRangeAsync Method
Definition
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.
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. 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. |
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. 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. |
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.
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.
public virtual System.Threading.Tasks.Task AddRangeAsync (params TEntity[] entities);
abstract member AddRangeAsync : 'Entity[] -> System.Threading.Tasks.Task
override this.AddRangeAsync : 'Entity[] -> System.Threading.Tasks.Task
Public Overridable Function AddRangeAsync (ParamArray entities As TEntity()) As Task
Parameters
- entities
- TEntity[]
The entities to add.
Returns
A task that represents the asynchronous operation.
Remarks
See EF Core change tracking and Using AddRange, UpdateRange, AttachRange, and RemoveRange for more information.
Applies to
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.
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.
public virtual System.Threading.Tasks.Task AddRangeAsync (System.Collections.Generic.IEnumerable<TEntity> entities, System.Threading.CancellationToken cancellationToken = default);
abstract member AddRangeAsync : seq<'Entity (requires 'Entity : null)> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.AddRangeAsync : seq<'Entity (requires 'Entity : null)> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function AddRangeAsync (entities As IEnumerable(Of TEntity), Optional cancellationToken As CancellationToken = Nothing) As Task
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
If the CancellationToken is canceled.
Remarks
See EF Core change tracking and Using AddRange, UpdateRange, AttachRange, and RemoveRange for more information.
Applies to
Feedback
Submit and view feedback for