I am using Entity Framework 6.
I have a table with test information called Tests. I am deleting rows from this table by first getting a list of the tests, doing a
I have made some test using EF6 and Sql Server Profiler
Using .RemoveRange()
It first fetch all record to delete from database
exec sp_executesql N'SELECT [Extent1].[Id] AS [Id], [Extent1].[IdOrder] AS [IdOrder], [Extent1].[Name] AS [Name], [Extent1].[Partita] AS [Partita], FROM [dbo].[MyTable] AS [Extent1] WHERE [Extent1].[IdOrder] = @p__linq__0',N'@p__linq__0 varchar(8000)',@p__linq__0='0cb41f32-7ccb-426a-a159-b85a4ff64c29'
Then it fire N delete command to database
exec sp_executesql N'DELETE [dbo].[MyTable] WHERE ([Id] = @0)',N'@0 varchar(50)',@0='ffea29aa-8ba5-4ac9-871b-3f5979180006'
X 1000 times
This happends also using and IQueriable
Using Entity Framework Extended Library
It fire only one command to database
exec sp_executesql N'DELETE [dbo].[MyTable] FROM [dbo].[MyTable] AS j0 INNER JOIN ( SELECT 1 AS [C1], [Extent1].[Id] AS [Id] FROM [dbo].[MyTable] AS [Extent1] WHERE [Extent1].[IdOrder] = @p__linq__0) AS j1 ON (j0.[Id] = j1.[Id])',N'@p__linq__0 nvarchar(36)',@p__linq__0=N'0cb41f32-7ccb-426a-a159-b85a4ff64c29'