EFCore.BulkExtensions | Entity Framework EF Core efcore Bulk Batch Extensions | SQL Database library
kandi X-RAY | EFCore.BulkExtensions Summary
kandi X-RAY | EFCore.BulkExtensions Summary
EntityFrameworkCore extensions: -Bulk operations (Insert, Update, Delete, Read, Upsert, Sync, Truncate) and -Batch ops (Delete, Update). Library is Lightweight and very Efficient, having all mostly used CRUD operation. Was selected in top 20 EF Core Extensions recommended by Microsoft. Current version is using EF Core 5 and is targeting NetStandard 2.1 so it can be used on project targeting Net 5. At the moment supports Microsoft SQL Server(2008+) and SQLite. Under the hood uses SqlBulkCopy for Insert, for Update/Delete combines BulkInsert with raw Sql MERGE. For SQLite there is no BulkCopy, instead library uses plain SQL combined with UPSERT. Bulk Tests can not have UseInMemoryDb because InMemoryProvider does not support Relational-specific methods. Available on Package manager console command for installation: Install-Package EFCore.BulkExtensions | Nuget | Target | Used EF v. | For projects targeting | | ----- | --------------- | ----------- | ------------------------------- | | 5.x | NetStandard 2.1 | EF Core 5.0 | Net 5+ | | 3.x | NetStandard 2.0 | EF Core 3.n | NetCore(3.0+) or NetFrm(4.6.1+) MoreInfo| | 2.x | NetStandard 2.0 | EF Core 2.n | NetCore(2.0+) or NetFrm(4.6.1+) | | 1.x | NetStandard 1.4 | EF Core 1.0 | NetCore(1.0+) |.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of EFCore.BulkExtensions
EFCore.BulkExtensions Key Features
EFCore.BulkExtensions Examples and Code Snippets
Community Discussions
Trending Discussions on EFCore.BulkExtensions
QUESTION
Using EFCore 3.1 with the library EFCore.BulkExtensions 3.6.1 (latest version for EFCore 3.1).
Database server is SQL Server 2019.
Here is code to reproduce the error.
A simple Customer class with a navigation property from another class:
ANSWER
Answered 2021-Jul-10 at 21:02As it stands right now, this is a bug in the EFCore.BulkExtensions library - versions 3.2.1 through 3.3.5 will handle it (mostly) correctly, versions 3.3.6 - 3.6.1 do not.
Use version 3.3.5 for the most stable result, as of this writing.
(No data on version 5.x for EFCore 5)
QUESTION
I'm using EFCore.BulkExtensions
to insert batches of, at most, 100,000 records into a database.
My issue is, for some reason, BulkInsertAsync
does not insert any records to the DB. I understand it's an asynchronous call, but I've waited half an hour and no data was inserted. The regular, synchronous BulkInsert
call works, but is extremely suboptimal since it hogs a ton of process time.
Does anyone have any idea why BulkInsertAsync
doesn't work in this context, but BulkInsert
does?
Here is the relevant code, which marshals binary data (transmitted from another machine) into a C struct, adds that C struct to a list, and then bulk-inserts the list into the database.
...ANSWER
Answered 2021-Feb-03 at 15:59The method should do something - if you await it.
So instead of:
db.BulkInsertAsync(records);
do:
await db.BulkInsertAsync(records);
Essentially, you told it to execute an async task, then you exited the method that created / owned the task by not calling await, causing the task to be abandoned. There's some subtle magic going on with the async tasks, LOL.
QUESTION
I am using BulkInsertOrUpdateAsync method to upsert the 20000 records in net-core 3.0. There is no error at all when doing this. it is upserting all the record with parent and child entity into database.
...ANSWER
Answered 2020-Nov-11 at 07:01Here is answer for this
QUESTION
Is there way with EF Core Bulk extensions to only update first few 10000 rows? write message, update next batch, write message in loop until complete?
I know there is Batch Size, however if there is only 5 million to update, and I want only update a certain amount, write a message, in continual loop until complete, how can this be done?
Should I use Top or Take?
I want to write "Hello", every few batches.
...ANSWER
Answered 2020-Aug-20 at 23:52It looks like BatchSize is only used for bulk insert. For update the expression is translated to a single SQL UPDATE statement, which doesn't operate by "batches".
QUESTION
I need to do bulk insert in ASP.NET Boilerplate and I tried to implement EFCore.BulkExtensions after reading https://github.com/aspnetboilerplate/aspnetboilerplate/issues/4397 .
I installed the latest EFCore.BulkExtensions from nuget into the project and I tried to use doContext as below so that I can use wherever required.
...ANSWER
Answered 2020-May-29 at 05:51I need to download a lower version of EFCore.BulkExtensions (2.4.7) nuget as the latest version did not support EF 2.2.4
QUESTION
I'm trying to use bulkinsert from EFCore.BulkExtensions in .NET Core 2.1 with one to one relationships. I have 2 Database Entities
...ANSWER
Answered 2020-Apr-23 at 23:13This is probably what you're looking for since you also want to insert child properties.
context.BulkInsert(Entity1ItemsList, options => options.IncludeGraph = true);
You can read further here:
QUESTION
I'm using EFCore BulkExtensions 2.5.0 with Entity Framework Core 2.2.3 and EFCore.SQLite 2.2.6.
I have code like this:
...ANSWER
Answered 2020-Mar-17 at 08:13Looks like this is a bug in EFCore.BulkExtensions for 2.5.0
where it didn't have full SQLite support. It works with version 2.6.4
: https://github.com/borisdj/EFCore.BulkExtensions/issues/308
QUESTION
I am getting the following error while using bulk insert from EF core bulk extensions:
Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index') at System.Collections.Generic.List
1.get_Item(Int32 index) at EFCore.BulkExtensions.TableInfo.UpdateEntitiesIdentity[T](IList
1 entities, IList1 entitiesWithOutputIdentity) at EFCore.BulkExtensions.TableInfo.LoadOutputData[T](DbContext context, IList
1 entities) at EFCore.BulkExtensions.SqlBulkOperation.Merge[T](DbContext context, IList1 entities, TableInfo tableInfo, OperationType operationType, Action
1 progress) at EFCore.BulkExtensions.DbContextBulkExtensions.BulkInsert[T](DbContext context, IList1 entities, BulkConfig bulkConfig, Action
1 progress)
at MyProject.Data.Repository.Repository1.CreateRange(List
1 entities)
I have a parent entity and child entity. What I am trying to do is, first bulk insert parent and then assign Ids generated for parent to their children. Then bulk insert children.
CreateRange
method:
ANSWER
Answered 2020-Feb-07 at 07:57The exception occurs due to the Ids being assigned before the bulk insert operation is conflicting with the Ids already existing in the database. The solution is to use Ids that are not in the database. For example, negative numbers. This can still preserve the order of insertion since what matters is the relative order between entities within the list to be inserted.
The modified code:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install EFCore.BulkExtensions
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page