Programming Entity Framework
Programming Entity Framework By Julia Lerman
February 2009
Pages: 828


Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Multiple Versions Of Sql Server Using Entity Framework
Ian B
post Jun 29 2009, 06:34 PM
Post #1


New Member
*

Group: Members
Posts: 4
Joined: 29-June 09
Member No.: 18,931



Dear Ms Lerhman,
I have been enjoying the book and extolling the virtues of the Entity Framework to my development team. To my chagrin I and another developer using EF hit the proverbial wall when trying to use multiple versions of the same database system. I am using the Entity Framework in a web application that utilizes SQL server 2000, 2005, and 2008. When I create a new EDMX file using anything other than 2008 (version of the first edmx created) I receive error 0172: All SSDL artifacts must target the same provider. The Provider 'MyDatabase' is different from ' MyDatabase ' that was encountered earlier. It seems that somewhere in the code the connection is wired to a 2008 datastore and when it checks the SSDL file and sees a different ProviderManifestToken value it throws this error. I am a little more than frustrated. It is hard to imagine that EF will only work with a single version of Sql Server per application. I am fairly sure there must be a setting or workaround. Does anyone have a solution to use different versions of SQL server and the Entity Framework within a single web application.

Thanks for any help,

Ian
Go to the top of the page
 
+Quote Post
Ian B
post Jun 30 2009, 11:51 AM
Post #2


New Member
*

Group: Members
Posts: 4
Joined: 29-June 09
Member No.: 18,931



One item of importance to mention is that I am in the middle of a migration from sql 2000 to sql 2008 and have changed the connection strings and performed an "Update Model From Database" oddly enough if I modify all of the SSDL to use ProviderManifestToken = "2005" the app works.
Go to the top of the page
 
+Quote Post
JulieLerman
post Jun 30 2009, 01:34 PM
Post #3


Active Member
****

Group: O'Reilly Author
Posts: 102
Joined: 17-September 08
Member No.: 836



Hi Ian

ProviderManifestToken is the attribute that I couldn't remember when I was replying to you on Twitter from the car (no I wasn't driving).

That is exactly the problem and you do have to change it manually. I get bit when I move projects from my dev machine (where I have SS2008) to my laptop (where I have SS2005).

You must change that attribute manually. The update wizard won't do it for you.

So if this is just a development, not production issue, you'll have to live with manually updating the token.

If you need to be able to switch at runtime you might just want to write some code that will modify the SSDL before you call it.

Remember that once you have made your first query, the metadata is loaded into the app namespsce. If you literally need to change in the middle of your app for some reason, then you'll have to edit the xml and then reload the SSDL into memory.

Check out this blog post
http://thedatafarm.com/blog/data-access/qu...ctions-to-load/

Mostly you'll get issues with date values but it's still a showstopper.

hth

julie
Go to the top of the page
 
+Quote Post
Ian B
post Jul 1 2009, 05:20 PM
Post #4


New Member
*

Group: Members
Posts: 4
Joined: 29-June 09
Member No.: 18,931



Julie,
First let me say that I truly appreciate that you are so open to helping. I think I have glossed over my goal in my efforts to get help. I am working in an organization that utilizes a single web application that hooks into many different databases hosted on a variety of RDBMS including Oracle, MSSQL 2000, MSSQL 2005, and MSSQL 2008. I was excited to use EF to homogenize the code used to access the different data sources. I was also thrilled because I could still use LINQ after hearing about MS no longer developing Linq2sql.
Anyhow I started building the DALs using EF to first access MSSQL 2005 dbs. All was great. Then I migrated the a database to a MSSQL 2008 server and changed the conn str for that particular db and refreshed the model from the database. The ProviderManifestToken (PMT) was updated to 2008 for the migrated EDM. Included in the Web App were other edmx files that pointed to other dbs located on the MSSQL 2005 server. This is where the trouble started. When I deployed to our development server I started getting the error

“error 0172: All SSDL artifacts must target the same provider. The Provider 'MyDatabase' is different from ' MyDatabase ' that was encountered earlier.”

I was able to get my application to work when I set all of the MSSQL Entity Data Models (EDM) PMT property to the same version. However this does worry me a little because of the differences in the different SQL versions and the t-sql that is generated from the Entity Framework.

This leaves my wondering about whether the issue was caused by the migration the EDM’s source from 2005 to 2008 after its creation?

Or

Is the issue that EF only supports one flavor of a particular RDBMS per Application?

Or

Is there some other .config, dll, msl, ssdl, or other file that has a contradicting value for the PMT associated with the upgraded data source, hence the version conflict stated in the error message?

I was able to get my application to work when I set the ProviderManifestToken property to the same version. However this does worry me a little because of the differences in the different SQL versions and the t-sql that is generated from the Entity Framework.

Great book! I have had to read the first 5 chapters several times because the density of critical information given. Hopefully this issue is not a show stopper for the use of EF in our enterprise web application.

I hope you are on .NET ROCKS soon to talk about EF 4 and your experiences with EF since the last show you did. That is how I got involved in EF in the first place

Ian
Go to the top of the page
 
+Quote Post
JulieLerman
post Jul 3 2009, 08:35 AM
Post #5


Active Member
****

Group: O'Reilly Author
Posts: 102
Joined: 17-September 08
Member No.: 836



Ian

I think I finally see what's happening. When an app starts up and makes its first query, it loads the metadata into the application process's memory. It stays there until either a) the application is ended or cool.gif you manually unload the metadata.

Since this is a web app, it just keeps running and running, so the metadata is still loaded. When you replace the SSDL file, I'm not sure what triggers EF to read that, but somehow it is seeing that this file is different than what's in memory.

So - what happens if you restart the app? Depending on how caching is being handled, current users will get screwed since their sessions will get killed.

Therefore what you might want to do is have a utility within the application that allows you to manually unload the metadata which would then automatically get reloaded next time anyone triggers a query or command to be created/executed. On p. 554 of my book there's informaiton about how to do this.

Let me know if I'm grokking your problem and if my response makes sense and seems like a reasonable way to solve the problem.

If I'm not there yet, I will call in the troops for support (i.e. someone from the EF team)

If I got this right, I'll certainly turn it into a blog post!

julie



julie
Go to the top of the page
 
+Quote Post
Ian B
post Jul 3 2009, 01:02 PM
Post #6


New Member
*

Group: Members
Posts: 4
Joined: 29-June 09
Member No.: 18,931



Julie,
I published the two entities to our dev server and then restarted the app pool and even did an iisreset. I received the same errors as before. I noticed that when in the error messages it explicitly defines the previously found ProviderManifestToken (PMT).

SQLDB2000.edmx = PMT =”2000”
SQLDB2005.edmx =PMT=”2008”

The error message reports…

Schema specified is not valid. Errors: SQLDB2008.ssdl(2,96) : error 0169: All SSDL artifacts must target the same provider. The ProviderManifestToken '2008' is different from '2000' that was encountered earlier.


Could the two EDM artifacts be getting compiled together? Seems that somehow the SSDLs for the two EDMs exist in the same container and are getting validated?

It appears that any new SQL EDM that is added to the Web Application falls into this condition.

I am unable to recreate the issue in a new Web app. The error is specific to the app, weird.

This is probably outside the scope of the book, I appreciate the help. Is there a better forum to ask this question? Perhaps to the EF team you mentioned?

Thanks for everything.

On Chapter 8 and working the examples. Tons to learn….



Ian
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 22nd November 2009 - 04:11 PM