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:
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 -->
5: <!-- SSDL content -->
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 :-(