Tag Archives: WPF

Using Sql Compact 4 in WPF Application project

Earlier today, i’m having trouble generating database model using Entity Framework and SQL CE 4 in WPF Application project.

after googling around, it seems there’s quite a few people that’s having the same problem, it’s a different story if you’re using it in a web application project, there’s a selection for SQL CE 4 when you’re trying to generate database like shown below.

here’s the workaround on getting the EF play nice on WPF app project:

    1. create a new WPF app project
    2. right click the project and select add new item
    3. choose sql compact 4
    4. right click the project and select add new item
    5. choose ADO.NET Entity Data Model
    6. on the EF Visual Designer, right click and choose Update Model from Database


notice that it doesn’t have SQL CE 4 as a data source

here’s what we’ll do

  1. right click the project and select add new item
  2. choose Application Configuration File
  3. open the configuration file, and add in this line below inside the configuration tag

notice the {EdmxFileName} and {EdmxContainerName} that i put on the connection string, fill it with the appropriate value.
now go back to the EF visual designer and choose Update model from database
now it will know the database that we specified in our application configuration file

Happy coding