7

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'm pretty much a beginner so that error message means nothing to me and I can't really continue the tutorial without completing this step. Big thank you to anyone who can help me here and I'll be sure to upvote the most helpful answer.

_________________________EDIT:

I've made it to this screen... seems like i have to choose the right one but I've never worked with this database stuff before so I really have no idea what to do here

SQL Custom Install Screen

7
  • Thanks a bunch I'm gonna check this out first thing in the morning. – Daniel Jun 13 '17 at 3:00
  • plugging everything in now @McDonald's – Daniel Jun 15 '17 at 19:47
  • 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 '17 at 20:05
  • I don't think I can add a pic here, @McDonald's check out the edit to the original post. – Daniel Jun 15 '17 at 20:42
  • 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 '17 at 18:32
7

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

1

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.

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.