Reputation: 13560
I created a entity framework 4.0 application by creating a model. The SQL Server Compact edition 4.0 database is created with this trick.
Now I finished all my code for importing the initial data into my database (Adding elements works fine). But if I try to access the elements via
Context context = new Context();
foreach (var c in context.Customers) // Exception
{
System.Diagnostics.Debug.Print(c.ToString());
}
it throws an exception at the start of the foreach loop:
[A]System.Data.SqlServerCe.SqlCeConnection cannot be cast to
[B]System.Data.SqlServerCe.SqlCeConnection. Type A originates from
'System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91' in the context 'Default' at location
'C:\Windows\assembly\GAC_MSIL\System.Data.SqlServerCe\4.0.0.0__89845dcd8080cc91\
System.Data.SqlServerCe.dll'. Type B originates from 'System.Data.SqlServerCe,
Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' in the context
'Default' at location 'C:\Windows\assembly\GAC_MSIL\System.Data.SqlServerCe\
3.5.1.0__89845dcd8080cc91\System.Data.SqlServerCe.dll'.
I added these references to my application:
System.Data.Entity - 4.0
System.Data.SqlServerCe - 4.0
System.Data.SqlServerCe.Entity - 4.0
Does anyone has an idea, what is wrong with my configuration?
PS: I want to use SQL CE 4.0 because of the computed values. If I need to use 3.5, I need to change my architecture (Or is it possible to implement something like computed values inside the context class?).
Upvotes: 2
Views: 2869
Reputation: 41749
I think your edmx file (look at it in a XML editor) still references 3.5, change that to 4.0
Upvotes: 9