Why there's no AddRange/RemoveRange method in IDbSet interface in Entity 6?

c# entity-framework entity-framework-6


The AddRange function has been introduced in Entity Framework 6. Due of DbSet, it's fantastic for large inserts. DetectChanges is always triggered by the Add method, which significantly slows down the workflow. When I saw that the IDbSet interface lacks an AddRange method, all I wanted to do was use some preexisting code based on it. It only appears in the DbSet class.

I did some research and came across this topic - http://forums.asp.net/t/1978828.aspx?Why+is+there+no+AddRange+method+for+System+Data+Entity+IDbSet+T+ - but there is no definitive answer as to why the AddRange method is actually absent from the IDbSet interface.

Is it a bug or is there a valid excuse why it shouldn't be there? Any thoughts?


Here's what Microsoft told me in response:

This is intentional. DbSet wasn't a good candidate for the interface method because adding members breaks any current apps that implement the interface.

We switched to a base class approach where DbSet is a base class that you can directly mimic or inherit since we want to be able to add members to DbSet.

Here are some websites that demonstrate using DbSet as opposed to IDbSet:



7/31/2015 2:54:43 PM

Accepted Answer

7/21/2015 1:34:51 PM

Popular Answer


Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow