Previously, I have blogged about SQL CE and how cool it is to use with .NET and Entity Framework. Now in VS2012 it was very simple to use. However, after VS2013 was introduced SQL CE support seemed to be discontinued and this made me very sad.
Sad because one of the great things about using SQL CE is that it needs no install. It can just be embedded into your project without any SQL installation. Now, there are some limits to SQL CE including no support for stored Procs and DB size limit of 4 GB, but for smaller projects particularly where you don’t need SQL installed on a hosted environment, it’s pretty cool.
However, after a little investigation and some great responses on stackoverflow including:
I came up with a little set of steps to get SQL CE and EF and VS2015 to work nicely. YAY!!!
- Start Visual Studio 2015
- Click New Project…
- Under Templates->Visual C#->Windows select Console Application
- From Tools select Extensions and Updates search for SQL Server Compact/SQLite Toolbox and once found Install
- Right Click on the Project and select Manage Nuget Packages and search for EntityFramework.SqlServerCompact and then once you have found this just click on Install ( You will need to then click OK and accept the agreement by clicking I accept)
- Build the project
- Under Tools select SQL Server Compact/SQLLite Toolbox
- Right Click on any SQL Server Compact Database and select Generate Code (EF/LINQ to SQL/SyncFX) -> Add Entity Data Model (EDMX) to current project
- Select all checkboxes for each table you wish to add to the model and click OK
- Now you’ll find an EDMX model created in your project for the database you selected above.
It’s not quite as easy as it was to use in VS2015 but its actually pretty easy to use.