i want write a api for bulk insert,how can u help me
Loading
i want write a api for bulk insert,how can u help me
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vishal YelvePosted Feb 23, 2023, 12:34 PM
Hi Sandeep,
I suggest you if you are want to Bulk Insert use EFCore.BulkExtensions.
please refer below article it will help you alot.
https://www.c-sharpcorner.com/article/bulk-operations-in-entity-framework-core/
Naimish MakwanaPosted Feb 23, 2023, 8:32 AM
You want to insert data in bulk. So why you want to use in loop?
As I see public List UserAccessList {get; set;} you're all the data are in list.
If you write code in for each, then there is no use of bulk insert.
Sandeep KumarPosted Feb 23, 2023, 8:27 AM
want to use for each one by one
Naimish MakwanaPosted Feb 23, 2023, 8:22 AM
You can write like this.
Need to create object of dbcontext.
Sandeep KumarPosted Feb 23, 2023, 8:19 AM
this my model class
this my method ,what i have write in for each
Naimish MakwanaPosted Feb 23, 2023, 8:15 AM
Hello Sandip
you can use N.EntityFramework.Extension
Once you install it, you can simply use BulkInsert() method directly on the DbContext instance. It supports BulkDelete, BulkInsert, BulkMerge and more.
Refer : https://stackoverflow.com/a/63101773/3054222
Thanks
Naimish Makwana