Recently I've been developing a small application using VS2008 SP1, Entity Framework and SQL Server 2008.  The target server is running Windows Server 2003 and SQL Server 2005. 

When I came to deploy my application I scripted the database and data (because you can't use SQL 2008 backups in 2005) and deployed my application, time to run and what do I get:

"Type datetime2 is not a defined system type"

Interesting!!  I check my database compatibility which looks fine for the target server:

image

It looks like Entity Framework ignores the underlying compatibility level, really useful right.

So to fix it, open the model in an xml editor and change the ProviderManifestToken to your target database.

   1: <?xml version="1.0" encoding="utf-8"?>
   2: <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
   3:   <!-- EF Runtime content -->
   4:   <edmx:Runtime>
   5:     <!-- SSDL content -->
   6:     <edmx:StorageModels>
   7:     <Schema Namespace="TcwsModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">

One thing to note is that if you update your model you'll need to update the above property again.

Why didn't I stick to NHibernate :-(


Posted in: Development  Tags:

Comments


July 23. 2009 18:22
trackback
Type datetime2 is not a defined system type - Entity Framework

You've been kicked (a good thing) - Trackback from DotNetKicks.com

http://www.dotnetkicks.com/database/Type_datetime2_is_not_a_defined_system_type_Entity_Frameworkhttp://www.dotnetkicks.com/database/Type_datetime2_is_not_a_defined_system_type_Entity_Framework


June 23. 2010 12:00
pingback
Pingback from iamhigham.com

Entity Framework users beware! « iamhigham.com

http://iamhigham.com/?p=21http://iamhigham.com/?p=21

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading



Calendar

«  May 2012  »
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
View posts in large calendar

Recent Comments

Banners

Theme Grabber
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012 Dan Gibbons .Net Developer