I'm following a tutorial for using C# in Microsoft Visual Studio 2017 Community edition. I'm supposed to add a new SQL Database to my project and give it the extension .sdf.

In the tutorial they choose it from the template menu that comes with the IDE but mine doesn't have the right one. The only database I see is "Service-based Database" which uses a .mdf extension and also throws me a small error/warning:

SQL Database error

Anyone know how to work around this?


I've made it to this screen... Seems like I have to choose the right one but I have no idea what to do here.

SQL Custom Install Screen

  • i had to install it on my second hard drive... hopefully there's a way to navigate to this from my Visual Studio install which is on hard drive #1...
    – Daniel
    Jun 15, 2017 at 20:05
  • ok @McDonald's i've gone through the setup video and did everything one by one but still no Local Databse option in my New Item list. The only database option is still the .mdf one and no .sdf in sight.
    – Daniel
    Jun 16, 2017 at 17:49
  • 1
    @McDonald's yea I just found this - msdn.microsoft.com/en-us/library/ms233763.aspx#Anchor_1 - so i guess im just gonna have to use a .mdf database and roll with the punches.
    – Daniel
    Jun 16, 2017 at 18:32

2 Answers 2


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)


SQL Server Express


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.


Further Resources


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


    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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.