Miha Markic

I have a somewhat weird situation. I have EDM defined for a single table and this piece of code:

Code Snippet
using (EntityConnection conn = new EntityConnection(ConfigurationManager.ConnectionStrings["Tubo"].ConnectionString))
using (EntityCommand cmd = new EntityCommand(
@"SELECT Prodaja.Leto, Prodaja.Stevilo FROM Tubo.Prodaja", conn))
{
conn.Open();
using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
{
DataTable table = new DataTable();
table.Load(reader); // I know this line won't work right now
}
}

The select is trivial. However, it will get stuck in ExecuteReader call and eventually it will throw out StackOverflowException. Initialy I thought there was a mapping problem but after hours of tweaking (and reducing) EDM files I got to this conclusion: It happens only when run in a WPF application. Same code, same mappings work in both Console and WinForms scenario. Even code like:

Code Snippet

var query = db.CreateQuery<Prodaja>("SELECT VALUE Prodaja FROM Tubo.Prodaja");
foreach (var item in query.)
Console.WriteLine(item.Leto);

would work reagrdless of environment.




Re: ADO.NET (Pre-release) EntityCommand throws StackOverflowException

Zlatko Michailov - MSFT

That¡¯s weird¡­ Entity Framework and WPF don¡¯t depend on each other¡­

We would like to investigate the T-SQL that gets generated, and the execution of the entity command. Can you please post:

¡¤ The exact connection string value. (Please blur UID and PWD if you have them there.)

¡¤ The T-SQL that generates the table.

¡¤ SSDL

¡¤ MSL

¡¤ CSDL

Thanks.

Zlatko Michailov

Program Manager, Data Programmability

Microsoft Corp.






Re: ADO.NET (Pre-release) EntityCommand throws StackOverflowException

Miha Markic

It is weird, indeed. Here you go.

app.config

Code Snippet

< xml version="1.0" encoding="utf-8" >
<configuration>
<connectionStrings>
<add name="Tubo" connectionString="metadata=.\Tubo.csdl|.\Tubo.ssdl|.\Tubo.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=MYSERVER;Initial Catalog=EntityFramework;Integrated Security=True&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>

SQL

Code Snippet

USE [EntityFramework]

GO

/****** Object: Table [dbo].[Prodaja] Script Date: 05/03/2007 18:46:29 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[Prodaja](

[ProdanoId] [int] IDENTITY(1,1) NOT NULL,

[Leto] [int] NOT NULL,

[NosilecId] [int] NOT NULL,

[Stevilo] [int] NOT NULL,

[Zasluzek] [decimal](18, 2) NULL,

[ZasluzekOK] [bit] NOT NULL,

[Spremenjen] [timestamp] NOT NULL,

CONSTRAINT [PK_Prodaja] PRIMARY KEY CLUSTERED

(

[ProdanoId] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Prodaja] WITH CHECK ADD CONSTRAINT [FK_Prodaja_GlasbeniNosilec] FOREIGN KEY([NosilecId])

REFERENCES [dbo].[GlasbeniNosilec] ([NosilecId])

GO

ALTER TABLE [dbo].[Prodaja] CHECK CONSTRAINT [FK_Prodaja_GlasbeniNosilec]

USE [EntityFramework]

GO

/****** Object: Table [dbo].[GlasbeniNosilec] Script Date: 05/03/2007 18:55:16 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[GlasbeniNosilec](

[NosilecId] [int] IDENTITY(1,1) NOT NULL,

[Skupina] [nvarchar](50) NOT NULL,

[Naslov] [nvarchar](2000) NOT NULL,

[Cena] [decimal](18, 2) NOT NULL,

[NaVoljo] [bit] NOT NULL,

[Spremenjen] [timestamp] NOT NULL,

CONSTRAINT [PK_GlasbeniNosilec] PRIMARY KEY CLUSTERED

(

[NosilecId] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

) ON [PRIMARY]

CSDL

Code Snippet

< xml version="1.0" encoding="utf-8" >
<Schema Namespace="EntityFrameworkModel" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
<EntityContainer Name="Tubo">
<EntitySet Name="Prodaja" EntityType="EntityFrameworkModel.Prodaja" />
</EntityContainer>
<EntityType Name="Prodaja" Key="ProdanoId">
<Property Name="ProdanoId" Type="Int32" Nullable="false" />
<Property Name="Leto" Type="Int32" Nullable="false" />
<Property Name="Stevilo" Type="Int32" Nullable="false" />
<Property Name="Zasluzek" Type="Decimal" Precision="18" Scale="2" />
<Property Name="ZasluzekOK" Type="Boolean" Nullable="false" />
<Property Name="Spremenjen" Type="Binary" Nullable="false" MaxLength="8" FixedLength="true" />
</EntityType>
</Schema>

SSDL

Code Snippet
< xml version="1.0" encoding="utf-8" >
<Schema Namespace="EntityFramework" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">
<EntityContainer Name="dbo">
<EntitySet Name="Prodaja" EntityType="EntityFramework.Prodaja" />
</EntityContainer>
<EntityType Name="Prodaja" Key="ProdanoId">
<Property Name="ProdanoId" Type="int" Nullable="false" StoreGeneratedPattern="identity" />
<Property Name="Leto" Type="int" Nullable="false" />
<Property Name="NosilecId" Type="int" Nullable="true" />
<Property Name="Stevilo" Type="int" Nullable="false" />
<Property Name="Zasluzek" Type="decimal" Scale="2" />
<Property Name="ZasluzekOK" Type="bit" Nullable="false" />
<Property Name="Spremenjen" Type="timestamp" Nullable="false" />
</EntityType>
</Schema>

MSL

Code Snippet

< xml version="1.0" encoding="utf-8" >
<Mapping xmlns:cs="urn:schemas-microsoft-com:windows:storage:mapping:CS" cs:Space="C-S" xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS">
<cs:EntityContainerMapping cs:StorageEntityContainer="dbo" cs:CdmEntityContainer="Tubo">
<cs:EntitySetMapping cs:Name="Prodaja" cs:TableName="Prodaja" cs:TypeName="EntityFrameworkModel.Prodaja">
<cs:ScalarProperty cs:Name="ProdanoId" cs:ColumnName="ProdanoId" />
<cs:ScalarProperty cs:Name="Leto" cs:ColumnName="Leto" />
<cs:ScalarProperty cs:Name="Stevilo" cs:ColumnName="Stevilo" />
<cs:ScalarProperty cs:Name="Zasluzek" cs:ColumnName="Zasluzek" />
<cs:ScalarProperty cs:Name="ZasluzekOK" cs:ColumnName="ZasluzekOK" />
<cs:ScalarProperty cs:Name="Spremenjen" cs:ColumnName="Spremenjen" />
</cs:EntitySetMapping>
</cs:EntityContainerMapping>
</Mapping>






Re: ADO.NET (Pre-release) EntityCommand throws StackOverflowException

Zlatko Michailov - MSFT

I don¡¯t find anything abnormal. I was suspecting that the generated T-SQL might be too complex but it¡¯s straightforward:

Code Snippet
SELECT
[Extent1].[Leto] AS [Leto],
[Extent1].[Stevilo] AS [Stevilo]
FROM [dbo].[Prodaja] AS [Extent1]

Are your apps running in real Windows or in a Virtual PC image

You mention the ExecuteReader() takes too long. Can you interrupt the execution after a few seconds and post the call stack from the exception.

Thanks.

Zlatko Michailov

Program Manager, Data Programmability

Microsoft Corp.






Re: ADO.NET (Pre-release) EntityCommand throws StackOverflowException

Miha Markic

Yes, it is running within VMWare Workstation 6 RC1 (build 44426)/Windows XP SP2 guest.

Apparently it gets stuck on this call (last line below)

user32.dll!7e418734()


Code Snippet
7E4186EA mov esi,dword ptr [ebp+0Ch]
7E4186ED test esi,esi
7E4186EF je 7E4186FD
7E4186F1 push 0
7E4186F3 push dword ptr [ebp+8]
7E4186F6 call 7E4186DB
7E4186FB mov dword ptr [esi],eax
7E4186FD push 1
7E4186FF push dword ptr [ebp+8]
7E418702 call 7E4186DB
7E418707 jmp 7E418ABC
7E41870C push ebp
7E41870D mov ebp,esp
7E41870F push esi
7E418710 push edi
7E418711 push ebx
7E418712 push 0DCBAABCDh
7E418717 push esi
7E418718 push dword ptr [ebp+18h]
7E41871B push dword ptr [ebp+14h]
7E41871E push dword ptr [ebp+10h]
7E418721 push dword ptr [ebp+0Ch]
7E418724 mov eax,dword ptr fs:[00000018h]
7E41872A or byte ptr [eax+0FB4h],1
7E418731 call dword ptr [ebp+8]
7E418734 mov ecx,dword ptr fs:[18h]

Judging from the fact that it happens within user32 dll it might be caused by virtual machine, right






Re: ADO.NET (Pre-release) EntityCommand throws StackOverflowException

Zlatko Michailov - MSFT

A similar problem was reported when Entity Framework is run in a Virtual PC image. The managed call stack was showing operations that should have completed before connection.Open() returned. So my assumption is CLR (or a layer underneath it) misbehaves in a virtual OS. It¡¯s out of Entity Framework¡¯s scope.

Zlatko Michailov

Program Manager, Data Programmability

Microsoft Corp.






Re: ADO.NET (Pre-release) EntityCommand throws StackOverflowException

Erick Thompson - MSFT

Is the MYSERVER you are referring to in your connecting string on the same machine image as the application That is, are you crossing the virtual machine boundary in the connection

Thanks,

Erick





Re: ADO.NET (Pre-release) EntityCommand throws StackOverflowException

Miha Markic

Hi Erick,

Yes, I am crossing the virtual machine boundary - MYSERVER is a separated (physical) computer.






Re: ADO.NET (Pre-release) EntityCommand throws StackOverflowException

Shawn Wildermuth-MVP

This might be related to my issue (it seems to happen both on a VPC and non-VPC):

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1425276&SiteID=1

I think this is an issue with WPF + EF *NOT* VPC. If I move the code to a console app or windows forms it succeeds. Now the real problem with you saying "It¡¯s out of Entity Framework¡¯s scope." is this is an incompatibility with different parts of .NET 3.0/3.5. I suspect if I post this over in the WPF forums they will say it outside of the WPF scope because its a EF problem. How do we get you guys to sit in a room together and test it






Re: ADO.NET (Pre-release) EntityCommand throws StackOverflowException

Srikanth Mandadi - MSFT

I have posted a reply in the above thread about the problem with WPF + EF( http://forums.microsoft.com/msdn/showpost.aspx postid=1425276&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=1 ).

We believe that the problem will be fixed in our next CTP. And apologies for the post earlier that this is out of Entity Framework's scope. Sometimes it is a little hard to figure out where the exact problem is when so many things are involved.

Thanks

Srikanth