Creating a SQL Server Compact Edition database file in Microsoft Visual Studio 2017

Creating a SQL Server Compact Edition database file in Microsoft Visual Studio 2017

Microsoft is dropping support for SDF files with Visual Studio

It appears Microsoft deprecated SQL Server Compact and it's suggested to use SQL Server Express moving forward instead.

The file extension for SQL Server Compact DB data files is SDF so just plan to the use SQL Server Express and its correlated MDF extension for its DB data file(s).


Microsoft Connect

Posted by Srini [MSFT] on 2/18/2013 at 11:52 AM

SQL Server compact edition is in deprecation mode with no new releases planned near future. Last release SQL CE 4.0SP1 (and earlier releases that are still in the support cycle) will continue to be supported through its lifecycle and Microsoft is committed to fix any major, production blocking issues found in these releases. At this point, we don't consider this issue to be in that category and hence we are closing this issue.

On the desktop/laptop deployments, migrating to SQL Server LocalDB/SQL Express is a possible option for many of the current users (http://msdn.microsoft.com/en-us/library/hh510202.aspx)

source


SQL Server Express

Deprecation

In February 2013, Microsoft announced that SQL Server Compact Edition had been deprecated.

Although no new versions or updates are planned, Microsoft will continue to support SQL Compact through their standard lifecycle support policy. This support will end in July 2021.

source


Further Resources

  • Download SQL Server Express
  • How to install SQL Server Express

SQLCE v4.0 is still available and is thriving. You can easily use it with any edition of Visual Studio 2019. You don't even have to install it—you can distribute it as a Private Deployment, bundled with your app.

Install this package, set some configurations in your project, and you're off and running.

It works great with Entity Framework 6.x Code First Migrations. I've had apps in production for years that use it. I couldn't be happier.

Here's a snippet from my data context class:

Partial Public Class Context
  Inherits DbContext

  Private Sub New(Connection As SqlCeConnection, LogSql As Boolean)
    MyBase.New(Connection, True)

    Dim sSessionSql As String

    Database.SetInitializer(New CreateDatabaseIfNotExists(Of Context))
    Database.SetInitializer(New MigrateDatabaseToLatestVersion(Of Context, Migrations.Configuration))

    Me.Database.Initialize(False)

    If Utils.Registry.LogSql OrElse LogSql Then
      sSessionSql = String.Empty

      Me.Database.Log = Sub(SqlCmd As String)
                          sSessionSql &= SqlCmd

                          EventLog.WriteEntry("SQL Log", sSessionSql, EventLogEntryType.Information)
                          sSessionSql = String.Empty
                        End Sub
    End If
  End Sub

  ...

End Class

As you can see, it creates a new database at startup if one doesn't already exist.

As a one-man ISV, I'd be out of business if I had to force my customer to download a +60MB installer just to run my small utilities.