O'Reilly Forums: Chapter 20 Sample - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Chapter 20 Sample

#1 User is offline   BrianHilltop 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 09-April 09

Posted 09 April 2009 - 09:31 AM

Once I build and run the sample the form comes up fine but upon selecting a customer in the drop down an exception it encountered in GetCustomerwithRelatedData.

It's a System.Data.EntityCommandExecutionException and the inner exception refers to "Type datetime2 is not a defined system type" amoung other things.

Is there something else I need to do to get this sample to work properly?

Thanks.
0

#2 User is offline   JulieLerman 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 334
  • Joined: 17-September 08

Posted 09 April 2009 - 09:58 AM

Hi Brian

Are you using the download code? I built those samples using SQL Server 2008. I had never thought of this problem. The model will contain an attribute that indicates it's for SS2008. If you are using SS2005, you will see this error.

Hopefully this is causing the problem because there's an easy fix!

Open up the entity data model in the XML Editor.

At the top of of the SSDL section the SCHEMA tag for the store has this attribute:

ProviderManifestToken="2008"

Change it to

ProviderManifestToken="2005"

Let me konw if this does the trick.

julie
0

#3 User is offline   BrianHilltop 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 09-April 09

Posted 09 April 2009 - 10:24 AM

yep that did the trick.
I was homing in on that change but didn't think it would be that easy.
After not finding any references to datetime2 I was looking for references to 2008 and the only thing I found was the ProviderManifestToken.

Thanks.
0

#4 User is offline   JulieLerman 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 334
  • Joined: 17-September 08

Posted 09 April 2009 - 10:29 AM

great. Now if this thread gets picked up by the search engines, the next person won't have to work as hard! :-)
0

#5 User is offline   BrianHilltop 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 09-April 09

Posted 09 April 2009 - 06:19 PM

One other question I have regarding this chapter sample...
When I try and pull up a non-customer, it hits an exception in CreateCustomerfromContact.

It's a System.Data.EntityCommandExecutionException stating "The data reader is incompatible with the specified 'BAModel.Customer'. A member of the type, 'CustTimeStamp', does not have a corresponding column in the data reader with the same name."

Any ideas?

Thanks.
0

#6 User is offline   cjohnson84 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 16-April 09

Posted 16 April 2009 - 07:36 AM

I am actually having the exact same problem except I am using SQL Server 2008 on a 64-bit PC. Any ideas what I may need to do in this case?

QUOTE (JulieLerman @ Apr 9 2009, 09:58 AM) <{POST_SNAPBACK}>
Hi Brian

Are you using the download code? I built those samples using SQL Server 2008. I had never thought of this problem. The model will contain an attribute that indicates it's for SS2008. If you are using SS2005, you will see this error.

Hopefully this is causing the problem because there's an easy fix!

Open up the entity data model in the XML Editor.

At the top of of the SSDL section the SCHEMA tag for the store has this attribute:

ProviderManifestToken="2008"

Change it to

ProviderManifestToken="2005"

Let me konw if this does the trick.

julie


0

#7 User is offline   JulieLerman 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 334
  • Joined: 17-September 08

Posted 16 April 2009 - 08:20 AM

hmm.. now that's odd.

My main development machine has SS2008 on an X64 Vista box.

if you created a new test model from the same database and only chose one or two obejcs from it, then looked at the XML, is the SSDL schema the same as the SSDL schema in the downloaded EDM?

Julie
0

#8 User is offline   PeteSut 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 13
  • Joined: 05-June 09

Posted 11 June 2009 - 04:17 AM

I've just hit this same issue as well, changing the ProviderManifestToken worked for me. It raises the question though, if development and deployment servers are different is there an easy way to manage this? If ProviderManifestToken is set to 2000 would it work on higher versions too or must it be exactly right?

Also, I hit Brian's 2nd problem too regarding converting contacts to customers. I solved it by adding an extra column, custtimestamp to the return values of the CreateCustomerfromContact stored procedure but this felt a bit clumsy: EF insisted it return both Customer.Timestamp and custtimestamp. What is the cause of this problem?
0

#9 User is offline   JulieLerman 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 334
  • Joined: 17-September 08

Posted 20 June 2009 - 05:36 AM

Hi Pete
Sorry for the delay as I was on vacation.

The provider manifest token is specific. I haven't tried it moving forward but it has bitten me a number of times when I have moved a project from the machine with SS2008 on it (an pmt="2008") to my laptop with SS2005 on it.

The place where I have been bit is when dealing with dates. FOr example, some date functions get translated to different SQL Server date functions for 2008.

If you have timestamp value in the contact then it will be inhertied in the customer and it is non-nullable. If you also have on in customer it too is non-nullable. Therefore you will be forced to populate both values in customer.

julie
0

#10 User is offline   PeteSut 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 13
  • Joined: 05-June 09

Posted 22 June 2009 - 12:39 AM

Thanks for the reply, hope you had a good vacation smile.gif

I can see where I went wrong with the timestamps now, your original stored procedure had select customer.* but did not select the contact timestamp which caused an error as the EF complained it could not find the column custtimestamp.
I modified it and replaced customer.* with the individual columns (excluding timestamp) and added a 'customer.timestamp as custtimestamp' column but the ef now complained it couldn't find a column called timestamp. I added customer.timestampback back into the stored procedure and it all worked which is what confused me. Now I realise it was matching the timestamp column up with the contact entity so I should have selected Contact.Timestamp instead.

Now I have one timestamp from customer, one from contact and it all makes more sense wink.gif
Sorry if I missed somewhere in the book where you explained all this.
0

#11 User is offline   JulieLerman 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 334
  • Joined: 17-September 08

Posted 03 July 2009 - 12:32 PM

just noting this as "closed"

julie
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users