Writing code is good exercise. RSS Feed


Entity Framework RTM Installation Experience

If you haven't been paying much attention to the release schedule of the Microsoft ADO.NET Entity Framework, you might not even know that it was finally released with SP1 of Visual Studio 2008. Having stirred up so much controversy among ORM enthusiasts, I was hoping for some election-year-worthy rhetoric and hyperbole from its critics, and either a flurry of praise or complaints from EF-user-hopefuls. Its release, however, was eerily quiet. I guess we'll just have to wait and see what comes up.

I was curious to see how the SP1 installation affected my existing EF Beta 2 installation and applications, so I installed SP1 without uninstalling EF Beta 2. The first thing I noticed when attempting to create a new Entity Data Model in a new application was this message:

Error: this template attempted to load an untrusted component 'Microsoft.Data.Entity.Design, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.  For more information on this problem and how to enable this template, please see documentation on Customizing Project Templates.

I had to double-take to see that I actually have two "ADO.NET Entity Data Model" templates in the Add New Item dialog. One of templates causes the error and the other one does not.

This is obviously because I had not uninstalled EF Beta 2. To fix this problem, uninstall the following programs:

  1. ADO.NET Entity Framework Tools Preview
  2. ADO.NET Entity Framework 1.0 (Pre-Release Version) (not really required to fix this issue, but it should be uninstalled anyway)

Next, I tried opening and running an old EF Beta 2 demo application I wrote. When attempting to open the .edmx file in the designer, I received the following error:

"Error 5: The required attribute 'Provider' is missing."

Similarly, attempting to build the solution gave me this error:

"Schema specified is not valid. Errors: Rockstars.ssdl(2,2) : error 0005: The required attribute 'Provider' is missing."

Apparently, the storage model (SSDL) schema has changed a bit. To fix the problem, I found the edmx:StorageModels element in my .edmx file and edited the code as shown below. (You may need to right-click on the .edmx file in Solution Explorer, and choose Open With --> XML Editor.)

From this:

<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="RockstarsModel.Store" Alias="Self" ProviderManifestToken="09.00.3054" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">

to this:

<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="RockstarsModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">

The other build error I was receiving was this:

"The type or namespace name 'RockstarsModel' could not be found (are you missing a using directive or an assembly reference?)" (In case you haven't figured it out yet, my program is called "Rockstars.")

This is due to a change in the way the generated data classes are namespaced. Previously, the generated data classes were placed in a top-level "model" namespace to represent the conceptual model (CSDL). This namespace had to be imported (or classes fully-qualified in code) in order to consume the data classes. In the RTM version, the classes are generated in your solution's default top-level namespace, so no import is necessary. The code gets re-generated at almost every move, so your old project will get updated to the new namespace pattern.

To fix my error I removed this line of code:

using RockstarsModel;

The most touted new feature in the RTM is the EntityDataSource. I'm a little skeptical that it's just another wizard, but hopefully I'll get a chance to look at it and blog about it. Other changes that may be of interest can be read about here. Some that caught my eye are:

  • In the SSDL (store definition), you can no longer use a period in the name of an Entity, Association, EntityContainer, EntitySet, AssociationSet, or Function.
  • The public DisposeContext() method has been removed from the EntityDataSourceView class.
  • The event argument classes for the EntityDataSource have been re-architected. This affects ASP.NET users who used the ContextCreating, ContextCreated, ContextDisposing, Selecting, Selected, Updating, Inserting, Deleting, and Deleted events.

All in all, the installation was pretty smooth, and migrating my Beta 2 application was pretty simple.

 
Posted by Tim Lee | 1 Comments | Trackback Url | Bookmark with:        
Tags:

Links to this Post

Comments

Thursday, 23 Oct 2008 01:49 by Thanks
This is just what I needed. Saved me a few hours of cursing. I had the same problem

Name:
URL:
Email:
Comments:

CAPTCHA Image Validation