How to insert same record in multiple times without using for loop because its taking to much time I want to insert 10lack record at a time
for (int i = 0; i < 1000; i++)
{
List<student> students = new List<student>
{
new Student{student_id = i,Name= "new"}
};
db.Set<Student>().AddRange(students);
db.SaveChanges();
}
This above code taking to much time to inserting 10lack record.is it possible to insert same Name with different student_id multiple times without using for loop?
SaveChanges()outside the loop area and declare theList<Student>before the loop. using this approach you can improve the performance of your code.