When to use .mdf and when .sdf?

user1555816 picture user1555816 · Sep 16, 2012 · Viewed 30.9k times · Source

After seeing a lot of things in the internet I haven't found any explanation between the two file types: .mdf and .sdf.

.sdf would be a compact version of SQL Server (.mdf) I believe. Still they appear utterly different.

Have followed the two tutorials on msdn, i.e. MVC Movie App and the Musicstore. Both use .sdf.

Partial quote (full): 'First of all it should be "|DataDirectory|ASPNETDBContext.mdf" (notice the extension difference). Your applic...'

Both tutorials have the connection string to .sdf, i.e.:

<add name             ="MovieDBContext"
     connectionString ="Data Source=|DataDirectory|Movies.sdf" 
     providerName     ="System.Data.SqlServerCe.4.0"
/>

<add name             ="MusicStoreEntities" 
     connectionString ="Data Source=|DataDirectory|MvcMusicStore.sdf" 
     providerName     ="System.Data.SqlServerCe.4.0"
/> 

Question:

My question is what to use where and when? More over why to use which where.

Answer

webdeveloper picture webdeveloper · Sep 16, 2012

SQL Server Compact (sdf files) popular in Windows phone for storing some data (small count of data), also it could be used in web sites, but it has poor performance, even SQLite is better.

SQL Server (mdf files) used in big sites with a lot of data. Its more powerful, but cant be used in phones and must be installed on servers.

Look this: Comparison of SQL Server Compact, SQL Server Express 2012 and LocalDB