Home > English > Problem Deploying WCF RIA Services using Entity Framework 4

Problem Deploying WCF RIA Services using Entity Framework 4

So I had my software tested and ready to deploy to the client. I installed the application on a local test server and confirmed that everything was working fine. It is using Silverlight 4, Prism, WCF RIA Services on top of Entity Framework 4. All seemed to be smooth sailing….

However, once I deployed to the client site on their internal servers, everything went wrong. After spending several days and installing Visual Studio on the client’s server to see what was wrong, I finally found the culprit. In hindsight, this may be a simple solution but when you are knee deep looking at code and configuration it is easy to overlook.

The problem turned out that I had developed and tested the application against SQL Server 2008. When I deployed the application to the client, their database instance is SQL Server 2005.

In the Entity Framework 4, it actually targets the database instance for obtaining the correct schema. There is no way to modify this in the Visual Designer or properties pane of Visual Studio. You must open the edmx document using the Xml (Text) Editor.

Here is a sample of what it looked like:

<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
  <!-- EF Runtime content -->
  <edmx:Runtime>
    <!-- SSDL content -->
    <edmx:StorageModels>
      <Schema Namespace="GlobalServices.Web.DataAccess.Store" 
        Alias="Self" Provider="System.Data.SqlClient" 
        ProviderManifestToken="2008">...</Schema>
    </edmx:StorageModels>
  <edmx:Runtime>
</edmx:Edmx>

Here is what it should look like:

<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
  <!-- EF Runtime content -->
  <edmx:Runtime>
    <!-- SSDL content -->
    <edmx:StorageModels>
      <Schema Namespace="GlobalServices.Web.DataAccess.Store" 
        Alias="Self" Provider="System.Data.SqlClient" 
        ProviderManifestToken="2005">...</Schema>
    </edmx:StorageModels>
  <edmx:Runtime>
</edmx:Edmx>

As you can see, the only difference is in the ProviderManifestToken attribute. All I had to do was change the value from 2008 to 2005.

If you have developed an application using Entity Framework and were targeting SQL Server 2008 but then needed to deploy to a client using SQL Server 2005, please be aware of this necessary change for your application to work.

NOTE: Also be aware that you may need to change more than this if you are using SQL Server 2008 specific data types, (e.g. datetime2).

Hope this helps….

Advertisements
  1. Duncan Watts
    June 29, 2010 at 1:28 pm

    I got hit by this one too, note that if you have multiple domain services in a project then all the manifest tokens have to match. I’m developing using a 2k8 instance and have to keep remembering to alter the token after any update.

    It would be nice to have a “compatibility mode” in there to prevent this requirement…

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/47d73f2d-65a7-4e6d-8a03-747280c1f829

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: