Daily Archives: April 3, 2012

Update to EF5 and DbLocal Default in Config

A few weeks ago I wrote a blog post showing how EF5 uses DbLocal as its default database along with a screenshot of the configuration info that EF5 puts into your config (web.config or app.config) of the project that you’ve installed EF5 into.

Since then, EF5 Beta 2 was released and the details have changed ever so slightly.

Now, instead of having a SqlConnectionFactory and critical elements of a connection string, we have a new factory, the LocalDbConnectionFactory.

Here is what the element looks like with EF5 Beta 2:

  <entityFramework>
    <defaultConnectionFactory 
type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <parameters> <parameter value="v11.0" /> </parameters> </defaultConnectionFactory> </entityFramework>

EF5: Where are my DataAnnotations?

EF 4.x:

EF 4.1+ has a DataAnnotations namespace for the new EF related annotations. Most of them are related to database schema.

image

EF 5

Not even a DataAnnotations namespace in here. That’s because the annotations got incorporated into .NET 4.5.

image

 

.NET 4.5

A new namespace within System.ComponentModel.DataAnnotations: “Schema”

All of the EF schema annotations are in here now. MaxLength and MinLength are in the DataAnnotations namespace.

image

Added the following thanks to a suggestion from Cecil Phillip

If you are using EF5 with .NET 4, there is a special version of the Entity Framework assembly which actually has the version 4.4.*.

The EF related DataAnnotations *are* in this assembly but notice they’ve been organized into regular and schema as they are in  .NET 4.5.

image