Last post May 06, 2016 08:03 PM by superjose
Apr 03, 2014 11:05 PM|TheNutCracker|LINK
The concrete implementation of a System.Data.Entity.DbSet<TEntity> has the .AddRange() method so it would seem logical to enforce this functionality through the interface itself versus adding it on after the fact. Why is the .AddRange() method not enforced
through a System.Data.Entity.IDbSet<T> inteface?
It looks the .AddRange() method was just recently added to System.Data.Entity.DbSet<TEntity> as of Entity Framework version 6.
It just boggles my mind why it isn't available through an IDbSet<T> type.
Apr 04, 2014 01:38 AM|vikineese|LINK
May be this will be of some help for you !!
Apr 10, 2014 04:33 AM|Terry Guo - MSFT|LINK
The AddRage method is declare in DbSet class, not in IDbSet interface, so if you want to use it, you need to add the DbSet reference.
The following links is the DbSet and IDbSet documentation:
Hope it helps.
Apr 10, 2014 11:29 AM|TheNutCracker|LINK
I realize there is no .AddRange() method in an IDbSet. That was part of my question. Why would there not be an .AddRange() method for an object that manipulates a DbSet? It's a little counter-intuitive.
Nov 15, 2014 06:33 PM|nTanonami|LINK
I had the same epiphany, I agree there is no reason except for not breaking code that already implements IDbSet - for whatever reason. In the meantime I solved it with extension methods - not pretty and hopefully compatible with some future IDbSet that implements
public static class R2VDbContextExtensionMethods
public static IEnumerable<TEntity> AddRange<TEntity>(this IDbSet<TEntity> dbset, IEnumerable<TEntity> entitiesToAdd) where TEntity : class
return ((DbSet<TEntity>) dbset).AddRange(entitiesToAdd);
public static IEnumerable<TEntity> RemoveRange<TEntity>(this IDbSet<TEntity> dbset, IEnumerable<TEntity> entitiesToDelete) where TEntity : class
return ((DbSet<TEntity>) dbset).RemoveRange(entitiesToDelete);
Yeah, half a year later
Still working on Windows 7 and happy with it.
May 06, 2016 08:03 PM|superjose|LINK
Thanks!!! It's working wonderfully!!