Welcome to MSDN Blogs Sign in | Join | Help

Communities To Communities 2008

Last Saturday I gave a talk at "Communities To Communities 2008" conference in Warsaw, Poland. I presented EDM and Entity Framework to an audience of >130 people - Polish MVPs and members of .NET User Groups (because of limited seating there was no open registration for .NET track).

Official videos and slide decks will follow, some community members have already published blog posts (mostly in Polish) and photos from the conference. Enjoy. The list below was compiled by Michal Grzegorzewski - Polish MVP who was one of the people that came up with the idea of a community conference and has driven it to become a real success.

Forums:
http://www.wss.pl/frmThread.aspx?tid=50120
http://www.wg.net.pl/
http://groups.google.com/group/plssug/t/66a3e4df8e684ee4
http://groups.google.com/group/kgd-net/t/8a74f2cdcef92c16

Blogs:
http://jacekciereszko.pl/2008/04/moje-wraenia-po-c2c-materiay.html
http://tomaszwisniewski.com/?p=39
http://pawlos.blogspot.com/2008/04/c2c-ju-po.html
http://bartekszafko.pl/index.php/blog/2008/04/06/c2c_2008_subiektywne...
http://blogs.msdn.com/danieb/archive/2008/04/07/pl-a-uj-e-nie-mog-em-...
http://zine.net.pl/blogs/sqlgeek/archive/2008/04/07/communities-to-co...
http://www.w2k.pl/c2c-bylem-chociaz-krtko/
http://www.maciejaniserowicz.com/post/2008/04/Relacja-z-Communities-t...

Photos:
http://picasaweb.google.com/warsaw.group.net/C2C2008
http://picasaweb.google.pl/krakow.group.net/C2C2008
http://www.flickr.com/photos/25384703@N03/sets/72157604405993622

Videos:
http://silverlight.services.live.com/invoke/49201/DinoEsposito/iframe...
http://www.youtube.com/watch?v=VZ7-WCZQgko

Posted by jkowalski | 4 Comments

Tips and Tricks for Debugging your Entity Framework Provider

Here are some tips that may be helpful when developing and testing a data provider that supports Entity Framework:

Tip #1 Validating SchemaInformation SSDL and MSL using EdmGen.exe

When developing an Entity Framework provider, one of the biggest tasks is preparing a store-specific mapping for SchemaInformation schema. Those mappings are quite complicated so it's easy to make a mistake.

You can validate that mapping with EdmGen utility:

1. Create an empty folder

2. Copy System.Data.Resources.DbProviderServices.ConceptualSchemaDefinition.csdl that ships with Sample Provider to that directory

3. Copy MyProvider.StoreSchemaDefinition.ssdl and MyProvider.StoreSchemaMapping.msl to the same place (adjust names as needed)

4. Open cmd.exe, cd to the folder and run (the following is a single line, no line breaks):

%WINDIR%\Microsoft.NET\Framework\v3.5\EdmGen
/mode:validateartifacts
/incsdl:System.Data.Resources.DbProviderServices.ConceptualSchemaDefinition.csdl
/inmsl:MyProvider.StoreSchemaMapping.msl
/inssdl:MyProvider.StoreSchemaDefinition.ssdl 

This will display a list of errors.

Tip #2 Generating a model from a database without using designer

You can use EdmGen.exe /mode:fullgeneration to generate set of schema files (CSDL,SSDL,MSL) from a database. This can be used instead of the designer, when using designer is nor preferable (for example in automated build environments). Since the the ADO.Net Entity Data Model Wizard will perform filtering based against your SchemaInformation schema, and EdmGen.exe does not perform any filtering, Getting things working with EdmGen.exe is a natural first step when debugging your SchemaInformation schema. See EdmGen.exe documentation for more information.

Because EdmGen.exe is just a thin layer on top of System.Data.Entity.Design.dll APIs it is easy to leverage those to get functionality equivalent to EdmGen in your test suite.

Tip #3 Query SchemaInformation using Entity SQL

There's a little-known API that can be used to create an EntityConnection that's based on SchemaInformation. All you have to do is to call CreateStoreSchemaConnection with provider invariant name and connection string. Once you have the EntityConnection, you can use it to query entity sets using Entity SQL.

For example, to list all tables whose names start with 's%' you can use the following code snippet:

using (EntityConnection ec = EntityStoreSchemaGenerator.CreateStoreSchemaConnection("System.Data.SqlClient", 
@"server=.\sqlexpress;integrated security=true")) { ec.Open(); using (EntityCommand cmd = ec.CreateCommand()) { cmd.CommandText = "SELECT VALUE t.Name FROM SchemaInformation.Tables AS t WHERE t.Name LIKE 's%'"; using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) { while (reader.Read()) { Console.WriteLine(reader.GetValue(0)); } } } }

Tip #4 Query SchemaInformation using LINQ To Entities

The same thing can be achieved using LINQ To Entities. We just need to generate appropriate classes with:

EdmGen.exe
/mode:entityclassgeneration
/incsdl:System.Data.Resources.DbProviderServices.ConceptualSchemaDefinition.csdl
/outobjectlayer:SchemaInformation.cs

And then the same query can be written as:

using (EntityConnection ec = 
        EntityStoreSchemaGenerator.CreateStoreSchemaConnection("System.Data.SqlClient", 
        @"server=.\sqlexpress;integrated security=true"))
{
    using (SchemaInformation si = new SchemaInformation(ec))
    {       

foreach (Table t in si.Tables.Where(c=>c.Name.StartsWith("s"))) { Console.WriteLine(t.Name); } } }

 

Tip #5 Common Error Messages and how to resolve them

  • error 0005: The 'PreferredMapping' attribute is not declared.

PreferredMapping attribute has been removed in Beta3. Remove it from the provider manifest XML file. Preferred mapping for each type is now resolved with GetEdmType() GetStoreType() functions - see our breaking changes details.

  • error 2041: There is no store type that maps to edm type '*' with the following facet values '*'. Please change the type or facets of property 'Id' in csdl to match with one of the store types.

Make sure that the provider manifest declares a type whose facets are compatible with your CSDL property. Using beta3, you may be able to work around the problem by adding an artificial type to the provider manifest just to satisfy mapping requirements. Post-beta3 we have changed mapping validation rules and we now ignore facet information in CSDL when validating mapping.

  • You get a store error that refers to EDM types (Int32, Int16, String) instead of store types (varchar, number, etc.)

In EF Beta3 the query tree that is sent to the provider has nodes annotated with conceptual types (not store types like in previous releases). You need to convert from C to S types. If your provider is based on Sample Provider you need to modify GetSqlPrimitiveType method in SqlGenerator.cs.

  • The given key was not present in the dictionary."; code 6003.

You may see this exception when the provider returns column Ordinal values which are zero-based instead of one-based. System.Data.Entity.Design APIs expect column ordinals to be one-based.

Posted by jkowalski | 2 Comments
Filed under:

Entity Framework Beta 2 released

Entity Framework Beta 2 and Entity Framework Tools CTP (both compatible with Orcas Beta 2 release) are finally out.

Release notes and download instructions are available at ADO.NET team' blog:

http://blogs.msdn.com/adonet/archive/2007/08/27/entity-framework-beta-2-the-1st-entity-framework-tools-ctp-released.aspx

Enjoy.

Posted by jkowalski | 0 Comments
Filed under:

Introduction

Welcome to my little piece of blogosphere. I'm a Software Design Engineer in Test and I'm currently working on Entity Framework. My areas of expertise are: provider manifest, primitive types in EDM & support for third-party providers. I am planning to write a series of articles that will describe each of these components from application developer's and provider writer's perspective.

I am originally from Poland. I moved to Redmond 9 months ago with my wife and daughter.

Posted by jkowalski | 0 Comments
Filed under:
 
Page view tracker