Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6127213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:28:40+00:00 2026-05-23T16:28:40+00:00

I created a entity framework 4.0 application by creating a model. The SQL Server

  • 0

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?).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:28:41+00:00Added an answer on May 23, 2026 at 4:28 pm

    I think your edmx file (look at it in a XML editor) still references 3.5, change that to 4.0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a new Entity Framework model from a database. This database has a
Situation I'm creating a C#/WPF 4 application using a SQL Compact Edition database as
I Am creating a web application and first use Entity Framework. I created Entity
I'm creating a WCF service that transfers entity objects created via entity framework. I
I have created a Dynamic Data site against an Entity Framework Model I have
I am creating an Entity Framework 4 application, and I need an unmapped property
I'm using Entity framework in web application. ObjectContext is created per request (using HttpContext),
I have an Application class. Entity framework created a navigation property called Assistants .
This is my first WinForm application using the Entity Framework and I have to
I'm new to Entity Framework. I've created a Multi Tier Application, in MVC, using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.