Monthly Archives: December 2007

Who’s preparing Entity Framework Providers?

I thought I saw this a week or so ago but couldn’t find it again, but it just appeared on David Sceppa’s blog.

“It” is a list of vendors who will have Entity Framework providers out within 3 months of Entity Framework’s release.

While Oracle is not on there DIRECTLY, there are 3rd party companies working on Oracle providers as well.

In the list are:

Oracle, MySQL, PostgreSQL, SQL Lite, DB2, Informax Dynamic Server, and VistaDB.

DataDirect will have their host of providers out sometime in 2008.

Firebird will have their db also sometime in 2008.

Get the details on David’s blog.

 

 

Are you using Entity SQL? Do not miss Zlatko’s blog

Zlatko Michailov has been posting some awesome stuff on his blog.

There are two that I want to highlight.

The first is because it helps me answer a question I am often asked is explaining why Entity Framework is not an ORM and how it compares/contrasts to ORMs.

The second is announcing that his tool that will REAAAAALLY help with writing ENtity SQL is now on codeplex; it’s called eSqlBlast. Zlatko demo’d this in his DevTEach session in Vancouver. HE wrote it himself and it is something like Query Builder for SQL SErver, where you can write queries (with the help of intellisense) and test them out rather than writing and debugging directly in your project (where there could be many other problems in the way that have nothing to do with syntax). It’s a must have tool for writing EntitySQL as we work our way into gaining experience and being more comfortable with it.

I must say that Zlatko’s blog post about eSqlBlast is pretty humble – just a few sentences. It’s a hugely impressive tool and he deserves gobs of praise for it. Try it out and let him know what you think!

Fun with ComicLife for our “christmas” letter

I had been thinking that I don’t want to write up a whole story about our year to put into the christmas cards for those distant relatives that we hardly ever see, yet I wanted to at least have a little something to share with them.

Then today, I got the perfect solution in the form of a friend’s holiday letter – she created a comic strip from a handful of pictures using Comic Life from plasq. THere are versions for WIndows and Mac. We printed out a bunch and also exported it to a jpg. Mine’s a little lame, but you can get very creative. Definitely a fun tool!

Click on the mini version to see it full size.

Embedding EDM schema files in Entity Framework Beta 3

Note: With the RTM of Entity Framework, the model’s Metadata Artifact Processing property is set to Embed in Output Assembly by default, whcih is the opposite of what is described in this blog post based on Beta 3.

One of the new features in Entity Framework Beta3 is the ability to embed the csdl, msl and ssdl schema files into the assembly which contains the model.

This is useful in scenarios where, like in a few of my solutions, you want to have a separate project to host the model and then use that project in various applications. In that case you need to make a reference to the dll with the model and the application using the model will need to know where to find the schema files through the metadata property of the special connection string.

At design time, you work with the EDMX file in the designer and you can also manually edit it’s XML if and when necessary. When the project is compiled, the 3 key sections of the EDMX file are spit out to the separate schema files (*.csdl, *.mls, *.ssdl) which are used by the EF APIs.

With the schema files embedded into the dll, we don’t have to keep track of the files.

Here’s how to pull it off. Note that there is a workaround in these instructions for a known bug.

My project that hosts the model is called AdventureWorksModel. In it are the model as well as some additional code that extends the functionality of the code generated classes.

By default, the EDMX file’s Build Action property is set to “EntityDeploy”. This is important to note in case you change it for some reason. It does need to be “EntityDeploy”. (I learned that the hard way, which is why I make a point of mentioning it.

Open the EDMX file in the design window and then you will see a new property in the property window called Metadata Artifact Processing. The default of this is “Copy to Output”.

To get around a current known bug, build the project with the property set to “Copy to Output”. Then change the Metadata Artifact Processing property to “Embed in Output Assembly”. Eventually you won’t need to build with Copy to Output first.

Build the project. After building, if you use a tool like Reflector, you can see the files have been compiled into the dll as in the screenshot below.

If you check the connection string in the app.config for the project you will see that there is a reference to the projects resources in the metadata properties, rather than to a file path.

<add name=“Entities”
connectionString=“metadata=res://*/AWModel.csdl|res://*/AWModel.ssdl|res://*/AWModel.msl;
provider=System.Data.SqlClient;provider connection string=&quot;
Data Source=127.0.0.1;Initial Catalog=AdventureWorksLT;Integrated Security=True;MultipleActiveResultSets=True&quot;”
providerName=“System.Data.EntityClient” />

Now you can reference the project or the dll directly, I have been successful with both methods.

The connection string in the model’s project needs to get copied into the config file of the app.

Then you should be good to go.

I did deploy the solution copying only the exe, the dll for the model and the app.config for the exe and it worked like a charm. No ssdl, csdl or msl files came along for the ride.

Thanks to Mike Kaufman and some others on the team for help as I tried to figure out how to get through this.

An arhitectural note… embedding the files will be useful in a number of scenarios. However there will also be many scenarios in which you do not want the schema files compiled into the dll so that you can replace them easily as needed without having to redeploy a dll. Granted with .NET, deploying a dll can be just as easy as deploying a new xml file, but I know there will be cases where I will prefer the loose coupling.

For those cases, I’ll want to work with the EntityDeploy msbuild task directly so that I can define the output location of the files that are built and easily maintain a common location as I did in this blog post which showed how to do it in Beta 2 (though that particular solution is no longer applicable). I’ll be fiddling with the msbuild task shortly.

ASP.NET Dynamic Data Support – use LINQ to SQL and (in the future) LINQ to Entities

Scott Guthrie has a post on Dynamic Data Support for ASP.NET that’s in the Extensions CTP. Based on my little rant from yesterday, I wanted to point out this:

One of the cool new features is something we call “ASP.NET Dynamic Data Support”.  In a nutshell this enables you to really quickly build data driven web-sites that work against a LINQ to SQL (and in the future LINQ to Entities) object model – and optionally allows you to-do this without having to build any pages manually.