EF BulkInsert() for ORM RRS feed

  • Question

  • Hi, 

    In our application we have Invoice and InvoiceItem classes like below:

        public class Invoice
            public int InvoiceId { get; set; }
            public string InvoiceNumber { get; set; }
            public DateTime InvoiceDate { get; set; }
            public List<InvoiceItem> InvoiceItems { get; set; }

        public class InvoiceItem
            public int InvoiceItemId { get; set; }
            public string ItemNumber { get; set; }
            public string PartDescription { get; set; }
            public int PartQuantity { get; set; }
            public double PartPrice { get; set; }

    Each Invoice could have multiple entries of InvoiceItem and they are linked by the InvoiceId field.

    This is how we set up our DBContext for Entity Framework.

        class AppDbContext : DbContext
            public AppDbContext() : base("DefaultConnection") { }
            public DbSet<Invoice> Invoices { get; set; }
            public DbSet<InvoiceItem> InvoiceItems { get; set; }

    When we call SaveChanges(), both tables were populated properly, but it takes a long time. We are trying to improve the performance by using BulkInsert() like below, but only the Invoice table is populated. The InvoiceItem table stays empty.

        using (AppDbContext dbContext = new AppDbContext())
       dbContext.BulkInsert(new List<Invoicce> { invoice });

    How could we resolve this problem, please?



    Monday, July 31, 2017 6:49 PM

All replies

  • Hi name wb,

    >>How could we resolve this problem, please?

    As far as I know, Entity framework does not support BulkInsert. it seems that you use some entity framework extension, which write by 3rd-party author. I would suggest that you could contact related author for suitable support.

    Thanks for your understanding.

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Tuesday, August 1, 2017 8:33 AM
  • Ok. Thank you for the reply.


    Tuesday, August 1, 2017 4:30 PM