Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Edited Issue: EF 4 - Conditional mapping makes memory consumption to reach huge values [352]

$
0
0
This issue was filed on Connect. A member of the EF team at Microsoft will need to follow up on the Connect bug when the issue is resolved. TFS ID: 444663

Repro files are available in the TFS bug referenced above.

Hello, The problem that I'm experiencing is occuring in a more complex scenario, but I'm able to reproduce it with a very simple case.

I have a model with two entities with a relation one to many. In the entities I have a column to handle soft delete. In the entity model I have a condition to retrieve only records that are not deleted.

When I want to retrieve all the entities that satisfy a given associated entity restriction, the memory reaches ~680MB.

Using SQL Server Management Studio I can see that the server is sending ~7KB of information!! The query that reaches SQL Server is full of LEFT OUTER JOINS

SELECT [Extent1].[Id] AS [Id], [Extent1].[FullName] AS [FullName], [Extent1].[AddressId] AS [AddressId], [Extent202].[Id] AS [Id1], [Extent202].[Name] AS [Name], [Extent202].[Number] AS [Number] FROM [dbo].[Person] AS [Extent1] LEFT OUTER JOIN [dbo].[Address] AS [Extent2] ON ([Extent2].[Deleted] = 0) AND ([Extent1].[AddressId] = [Extent2].[Id]) LEFT OUTER JOIN [dbo].[Address] AS [Extent3] ON ([Extent3].[Deleted] = 0) AND ([Extent1].[AddressId] = [Extent3].[Id]) LEFT OUTER JOIN [dbo].[Address] AS [Extent4] ON ([Extent4].[Deleted] = 0) AND ([Extent1].[AddressId] = [Extent4].[Id]) LEFT OUTER JOIN [dbo].[Address] AS [Extent5] ON ([Extent5].[Deleted] = 0) AND ([Extent1].[AddressId] = [Extent5].[Id]) LEFT OUTER JOIN [dbo].[Address] AS [Extent6] ON ([Extent6].[Deleted] = 0) AND ([Extent1].[AddressId] = [Extent6].[Id]) ... WHERE ((N'317 Oak Blvd.' = [Extent2].[Name]) AND (926 = [Extent3].[Number])) ...

If I remove the conditional mapping all works well. Why does EF needs to generate so many information? This is a EF known bug?

In attach: script_DemoEF.zip - script to create database
generatedQuery.sql - Query that the application executes
DemoEF.zip - CSharp application to replicate the problem


Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>