<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>SQL Server Express WebLog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/sqlexpress/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/sqlexpress/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 04 Nov 2015 06:40:00 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>SQL Server Express and Windows 8</title>
      <link>https://docs.microsoft.com/archive/blogs/sqlexpress/sql-server-express-and-windows-8</link>
      <pubDate>Fri, 02 Mar 2012 10:03:00 GMT</pubDate>
      <dc:creator><![CDATA[sqlexpress]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sqlexpress/2012/03/02/sql-server-express-and-windows-8/</guid>
      <description><![CDATA[With Windows 8 Consumer Preview released I thought it would be good to clarify for our users which...]]></description>
      <content:encoded><![CDATA[With Windows 8 Consumer Preview released I thought it would be good to clarify for our users which SQL Server Express versions will be supported on Windows 8. Here they are:

<ul>  <li>SQL Server 2008 Express <b>SP3</b> and above.</li>  <li>SQL Server 2008 R2 Express <b>SP1</b> and above.</li>  <li>SQL Server 2012 Express.</li>  </ul>

Additional Notes:

<ul>  <li>SQL Server <b>2005</b> Express will not be suported on Windows 8.</li>  <li>SQL Server Express is not supported on Windows on ARM.</li>  </ul>

I hope you find this summary useful.

- Krzysztof Kozielczyk

<p></p><h3>Share Your Feedback</h3><p>Please share your feedback with us! Just start a thread on <a href="https://social.msdn.microsoft.com/Forums/sqlexpress/">SQL Express Forum</a>, hit the "Email Author" button on this post, or file a <a href="https://connect.microsoft.com/SQLServer">Connect</a> item!</p>]]></content:encoded>
    </item>
    <item>
      <title>Using LocalDB with Full IIS, Part 2: Instance Ownership</title>
      <link>https://docs.microsoft.com/archive/blogs/sqlexpress/using-localdb-with-full-iis-part-2-instance-ownership</link>
      <pubDate>Thu, 08 Dec 2011 23:17:00 GMT</pubDate>
      <dc:creator><![CDATA[sqlexpress]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sqlexpress/2011/12/08/using-localdb-with-full-iis-part-2-instance-ownership/</guid>
      <description><![CDATA[This is the second post in a two-post mini-series on using LocalDB with Full IIS. Don't...]]></description>
      <content:encoded><![CDATA[<p>This is the second post in a two-post mini-series on using LocalDB with Full IIS. Don't miss&nbsp;the <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-1-user-profile.aspx">first post</a>.</p>
<h3>Quick Recap</h3>
<p>In the <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-1-user-profile.aspx">first post</a> of this mini-series we said there are two properties of LocalDB causing problems when running under full IIS:</p>
<ul>
<li>LocalDB needs user profile to be loaded</li>
<li>LocalDB instance is owned by a single user and private (by default)</li>
</ul>
<p>We saw how to properly load the user profile, now it's time to tackle the problem of LocalDB instance ownership.</p>
<h3>The Problem of the Private Instance</h3>
<p>At the end of the previous post we left our Web Application in this state:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/4278.1.0_AspNetFailure2.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/4278.1.0_5F00_AspNetFailure2.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/4278.1.0_AspNetFailure2.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/4278.1.0_5F00_AspNetFailure2.png" /></a></p>
<p>As we can see we are facing the following error:</p>
<p style="margin: 20px; color: #800000;" color="#800000"><i><b>System.Data.SqlClient.SqlException:</b> Cannot open database "OldFashionedDB" requested by the login. The login failed.<br /> Login failed for user 'IIS APPPOOL\ASP.NET v4.0'.</i></p>
<p>This time the error is quite clear. LocalDB was started and the Web Application was able to connect to it, but the connection was then terminated due to login failure. The ApplicationPoolIdentity account for the IIS application pool (in this case <b>IIS APPPOOL\ASP.NET v4.0</b>) couldn't login to LocalDB instance because the database specified in the connection string (<b>OldFashionedDB</b>) wasn't found. How odd, since connecting from Visual Studio with the same connection string succeeds!</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/2451.1_1.TheDbIsThere.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/2451.1_5F00_1.TheDbIsThere.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/2451.1_1.TheDbIsThere.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/2451.1_5F00_1.TheDbIsThere.png" /></a></p>
<p>(In this screenshot I am using SQL Server Object Explorer, which is introduced by <a href="https://blogs.msdn.com/b/ssdt/archive/2011/11/21/what-s-new-in-sql-server-data-tools-ctp4.aspx">SQL Server Data Tools</a>. As you can see it adds SQL Server tools right inside Visual Studio 2010.)</p>
<p>How is it possible that Visual Studio connects to LocalDB just fine, while the connection from Web Application fails? In both cases the connection string is the following:</p>
<p style="margin: 20px;"><span style="font-family: Consolas; color: #000000;" face="Consolas" color="#000000">Data Source=(localdb)\v11.0;Initial Catalog=OldFashionedDB;Integrated Security=True</span></p>
<p>The answer is that there are <b>two</b> different LocalDB instances here. Unlike SQL Server Express instances, which are running as Windows services, LocalDB instances are running as user processes. When different Windows users are connecting to LocalDB, they will end up with different LocalDB processes started for each of them. When we connect to <b>(localdb)\v11.0</b> from Visual Studio, a LocalDB instance is started for us and runs as our Windows account. But when Web Application, running in IIS as ApplicationPoolIdentity, is connecting to LocalDB, another LocalDB instance is started for it and is running as ApplicationPoolIdentity! In effect, even though both Visual Studio and Web Application are using the same LocalDB connection string, they are connecting to different LocalDB instances. Obviously the database created from Visual Studio on our LocalDB instance will not be available in Web Application's LocalDB instance.</p>
<p>A good analogy to this is <b>My Documents</b> folder in Windows. Say we open Visual Studio and create a file in our <b>My Documents</b> folder. Then we login to the same machine as a different user and go to <b>My Documents</b> folder again. We won't find the file there as <b>My Documents</b> of the second user and our <b>My Documents</b> are two different folders. Similarly LocalDB instances <b>(localdb)\v11.0</b> owned by two different users are two different processes with two different sets of databases.</p>
<p>This is also the reason the Web Application was able to connect to LocalDB from IIS Express. Just like LocalDB, IIS Express is a user process. It is started by Visual Studio and runs as the same Windows account as the Visual Studio process. Two different processes running as the same Windows account (Visual Studio and IIS Express, both running as our Windows account) connecting to <b>(localdb)\v11.0</b> are connecting to the same LocalDB process, also started as the same Windows account.</p>
<h3>Possible Solutions</h3>
<p>Understanding the nature of the problem brings multiple approaches to solving it. As different approaches have different tradeoffs, instead of prescribing one solution, below I presented three approaches that seem most viable to me. My hope is to hear from you about the one that worked best for you! Here is the list:</p>
<ul>
<li><a href="#OurIIS">Approach 1: Run IIS as our Windows user</a></li>
<li><a href="#SharedLocalDB">Approach 2: Use LocalDB Shared Instance</a></li>
<li><a href="#UseSSE">Approach 3: Use full SQL Server Express</a></li>
</ul>
<p>Let's take a closer look at each of them.</p>
<h3><a name="OurIIS"></a>Approach 1: Run IIS as our Windows user</h3>
<p>If different user accounts are the problem, why not try to run our Web Application under our Windows account? Web Application would connect to the same LocalDB as Visual Studio and everything should just work.</p>
<p>Making the configuration change is relatively easy, just start IIS Manager and find the right Application Pool:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/6114.2_1.ConfigureCurrentUser1.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/6114.2_5F00_1.ConfigureCurrentUser1.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/6114.2_1.ConfigureCurrentUser1.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/6114.2_5F00_1.ConfigureCurrentUser1.png" /></a></p>
<p>Open <b>Advanced Settings</b> screen (available in the context menu):</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/6011.2_2.ConfigureCurrentUser2.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/6011.2_5F00_2.ConfigureCurrentUser2.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/6011.2_2.ConfigureCurrentUser2.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/6011.2_5F00_2.ConfigureCurrentUser2.png" /></a></p>
<p>Click the little button in the <b>Identity</b> property to bring up the <b>Application Pool Identity</b> screen:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/4762.2_3.ConfigureCurrentUser3.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/4762.2_5F00_3.ConfigureCurrentUser3.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/4762.2_3.ConfigureCurrentUser3.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/4762.2_5F00_3.ConfigureCurrentUser3.png" /></a></p>
<p>Starting the Web Application again will confirm that the problem is solved:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/7183.X_0.Success.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/7183.X_5F00_0.Success.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/7183.X_0.Success.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/7183.X_5F00_0.Success.png" /></a></p>
<p>What are the drawbacks of this approach? Of course running Web Application under our account brings certain <b>security risks</b>. If someone hijacks our Web Application they will be able to access all system resources our account can. Running the Web Application as ApplicationPoolIdentity provides additional protection since ApplicationPoolIdentity accounts have very limited access to local system resources. Therefore I cannot recommend this approach in general, but when used with care it is a viable option in some cases.</p>
<h3><a name="SharedLocalDB"></a>Approach 2: Use LocalDB Shared Instance</h3>
<p>We could also use an instance sharing feature of LocalDB. It allows us to share a LocalDB instance with other users on the same machine. The shared instance will be accessible under a public name.</p>
<p>The easiest way of sharing an instance is to use <a href="https://msdn.microsoft.com/en-us/library/hh212961(v=sql.110).aspx">SqlLocalDB.exe</a> utility. Just start an administrative command line prompt, and type the following command:</p>
<p style="margin: 20px;"><span style="font-family: Consolas; color: #000000;" face="Consolas" color="#000000">sqllocaldb share v11.0 IIS_DB</span></p>
<p>It will share the private LocalDB instance <b>v11.0</b> under the public name <b>IIS_DB</b>. All users on the machine will be able to connect to this instance, using <b>(localdb)\.\IIS_DB</b> as a server address. Note the <b>\.</b> before the instance name, indicating this is a shared instance name. We should replace the connection string in our Web Application with an updated one:</p>
<p style="margin: 20px;"><span style="font-family: Consolas; color: #000000;" face="Consolas" color="#000000">Data Source=(localdb)\.\IIS_DB;Initial Catalog=OldFashionedDB;Integrated Security=True</span></p>
<p>Before the shared instance can be used by the Web Application we need to start it and create logins for the ApplicationPoolIdentity. Starting the instance is easy, simply connecting to it from SQL Server Object Explorer will start it and keep it alive. Once we are in the SQL Server Object Explorer we can also create the login for ApplicationPoolIdentity. We could use the following query:</p>
<p style="margin: 20px;"><span style="font-family: Consolas; color: #0000ff;" face="Consolas" color="#0000ff">create login <span style="color: #008080;" color="#008080">[IIS APPPOOL\ASP.NET v4.0]</span> from windows;<br /> exec <span style="color: #800000;" color="#800000">sp_addsrvrolemember</span> <span style="color: #ff0000;" color="#ff0000">N'IIS APPPOOL\ASP.NET v4.0'</span>, <span style="color: #008080;" color="#008080">sysadmin</span> </span></p>
<p>This script gives full administrative access to our LocalDB instance to the ApplicationPoolIdentity account. Whenever possible, I would recommend using more limited, database-level or even table-level permissions.</p>
<p>Now we can run our Web Application again. This time it should work just fine:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/7183.X_0.Success.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/7183.X_5F00_0.Success.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/7183.X_0.Success.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/7183.X_5F00_0.Success.png" /></a></p>
<p>What are the drawbacks of this approach? The main one is that, before Web Application can connect to the shared instance, we need to make sure the instance is started. For that to happen the Windows account that owns the instance must connect to it and the connection must be kept open, or the LocalDB instance will shut down.</p>
<h3><a name="UseSSE"></a>Approach 3: Use full SQL Server Express</h3>
<p>Since full IIS runs as a service, maybe using traditional, service-based SQL Server Express is the right approach? We could just install SQL Server 2012 Express RC0 and create the <b>OldFashionedDB</b> database in it. We can even use our brand new SQL Server Data Tools to do it, as it works with any SQL Server version and edition. Our connection string would have to change to:</p>
<p style="margin: 20px;"><span style="font-family: Consolas; color: #000000;" face="Consolas" color="#000000">Data Source=.\SQLEXPRESS;Initial Catalog=OldFashionedDB;Integrated Security=True</span></p>
<p>Of course, just as in the previous case, we would need to make sure the ApplicationPoolIdentity account has access to our SQL Server Express instance. We can use the same script as previously:</p>
<p style="margin: 20px;"><span style="font-family: Consolas; color: #0000ff;" face="Consolas" color="#0000ff">create login <span style="color: #008080;" color="#008080">[IIS APPPOOL\ASP.NET v4.0]</span> from windows;<br /> exec <span style="color: #800000;" color="#800000">sp_addsrvrolemember</span> <span style="color: #ff0000;" color="#ff0000">N'IIS APPPOOL\ASP.NET v4.0'</span>, <span style="color: #008080;" color="#008080">sysadmin</span> </span></p>
<p>After that, running our Web Application brings the happy picture again:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/7183.X_0.Success.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/7183.X_5F00_0.Success.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/7183.X_0.Success.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/7183.X_5F00_0.Success.png" /></a></p>
<p>What are the drawbacks of this approach? Obviously we lose the benefits of using LocalDB. Installing SQL Server Express may take more time than LocalDB, and there may be some machine cleanup necessary for it to succeed. SQL Server Express Setup can be blocked by problems like corrupt WMI database, polluted registry or components left by SQL Server or Visual Studio CTPs and Betas. And SQL Server Express will continue running in the background even when not needed, as services do.</p>
<h3>Other options</h3>
<p>There are other approaches of using LocalDB under full IIS that are not covered here. We could embrace the Web Application's private LocalDB instance and communicate with it through the Web Application by executing T-SQL scripts from ASP.NET code. We could also use AttachDbFileName option of ADO.NET connection strings and use a database file (.mdf) that would be attached to both our LocalDB during development and Web Application's LocalDB for debugging. I tried both I found them too cumbersome to discuss further.</p>
<h3><a name="TryItNow"></a>Try It Now!</h3>
<p>We are eager to hear your feedback on LocalDB. Please share your thoughts with us. Did any of the approaches presented in this post work for you? Did you figure out a better one? Let us know!</p>
<p>You may also want to see other posts and materials about LocalDB:</p>
<ul>
<li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx">Introducing LocalDB and LocalDB Q&amp;A</a></li>
<li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/27/net-framework-4-now-supports-localdb.aspx">Upgrading .NET Framework 4 to support LocalDB connections and using SQL Server Management Studio to work with LocalDB</a></li>
<li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/11/28/using-localdb-in-visual-studio-2010.aspx">Using LocalDB in Visual Studio 2010</a></li>
<li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-1-user-profile.aspx">Using LocalDB in Full IIS, Part 1: User Profile</a></li>
<li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-2-instance-ownership.aspx">Using LocalDB in Full IIS, Part 2: Instance Ownership</a></li>
<li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/11/28/simple-installer-for-localdb-has-shipped.aspx">LocalDB RC0 and the New LocalDB Installer</a></li>
<li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/28/localdb-where-is-my-database.aspx">Where are LocalDB database files located?</a></li>
<li><a href="https://msdn.microsoft.com/en-us/library/hh510202(v=sql.110).aspx">SQL Server 2012 Express LocalDB documentation [preview]</a></li>
</ul>
<p>- Krzysztof Kozielczyk</p>
<p></p>
<h3>Share Your Feedback</h3>
<p>Please share your feedback with us! Just start a thread on <a href="https://social.msdn.microsoft.com/Forums/sqlexpress/">SQL Express Forum</a>, hit the "Email Author" button on this post, or file a <a href="https://connect.microsoft.com/SQLServer">Connect</a> item!</p>]]></content:encoded>
    </item>
    <item>
      <title>Using LocalDB with Full IIS, Part 1: User Profile</title>
      <link>https://docs.microsoft.com/archive/blogs/sqlexpress/using-localdb-with-full-iis-part-1-user-profile</link>
      <pubDate>Thu, 08 Dec 2011 23:14:00 GMT</pubDate>
      <dc:creator><![CDATA[sqlexpress]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sqlexpress/2011/12/08/using-localdb-with-full-iis-part-1-user-profile/</guid>
      <description><![CDATA[This is the first post in two-post mini-series on using LocalDB with Full IIS. If you found it...]]></description>
      <content:encoded><![CDATA[<p>This is the first post in two-post mini-series on using LocalDB with Full IIS. If you found it useful make sure to continue to the <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-2-instance-ownership.aspx">second post</a>.</p>
<h3>LocalDB and Full IIS</h3>
<p>In <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/11/28/using-localdb-in-visual-studio-2010.aspx">this recent post</a> I described how to use SQL Server Express LocalDB with Visual Studio 2010. The approach I proposed works for all kind of projects, including Web Applications. However, when it comes to Web Application, there is a catch. An application hosted in Cassini or IIS Express will work as expected, but as soon as we try running it in full IIS (the regular IIS that comes with Windows and runs as Windows service) we are facing the following error:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/0312.0.0_AspNetFailure.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/0312.0.0_5F00_AspNetFailure.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/0312.0.0_AspNetFailure.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/0312.0.0_5F00_AspNetFailure.png" /></a></p>
<h3>What Went Wrong?</h3>
<p>There are two properties of LocalDB that cause problems when running under full IIS:</p>
<ul>
<li>LocalDB needs user profile to be loaded</li>
<li>LocalDB instance is owned by a single user and private (by default)</li>
</ul>
<p>We will focus the rest of this post on the user profile, leaving the issue of LocalDB instance ownership for the <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-2-instance-ownership.aspx">next post</a>.</p>
<h3><a name="LoadProfile"></a>Loading User Profile</h3>
<p>Let's take another look at the error:</p>
<p style="margin: 20px; color: #800000;" color="#800000"><i><b>System.Data.SqlClient.SqlException:</b> A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 0 - [x89C50120])</i></p>
<p>The error message is not very helpful but LocalDB stores additional information in Windows Event Log. Looking in the <b>Application</b> section under <b>Windows Logs</b> we find the following message:</p>
<p style="margin: 20px; color: #800000;" color="#800000"><i>Windows API call SHGetKnownFolderPath returned error code: 5. Windows system error message is: Access is denied.<br /> Reported at line: 400.</i></p>
<p>Followed by this one:</p>
<p style="margin: 20px; color: #800000;" color="#800000"><i>Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.</i></p>
<p>Most likely there will be several copies of these two errors, as ADO.NET connection logic attempts to connect multiple times at different intervals:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/4135.0_1.EventLog.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/4135.0_5F00_1.EventLog.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/4135.0_1.EventLog.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/4135.0_5F00_1.EventLog.png" /></a></p>
<p>The second message is clear, the problem we're facing is that the user profile needs to be loaded. That shouldn't be hard since each IIS Application Pool has an option called <b>Load User Profile</b> that can be found in <b>Advanced Settings</b> section. Unfortunately things got slightly more complicated in Service Pack 1 for Windows 7. As described in <a href="https://support.microsoft.com/kb/2547655">KB 2547655</a> enabling <b>loadUserProfile</b> is not enough to fully load user profile, we also need to enable <b>setProfileEnvironment</b>. This requires editing <b>applicationHost.config</b> file which is usually located in C:\Windows\System32\inetsrv\config. Following the instructions from <a href="https://support.microsoft.com/kb/2547655">KB 2547655</a> we should enable both flags for Application Pool <b>ASP.NET v4.0</b>, like this:</p>
<p style="margin: 20px;"><span style="font-family: Consolas; color: #0000ff;" face="Consolas" color="#0000ff"> <span style="color: #0000ff;" color="#0000ff">&lt;</span><span style="color: #800000;" color="#800000">add</span> <span style="color: #ff0000;" color="#ff0000">name</span>=<span style="color: #000000;" color="#000000">"</span><span style="color: #0000ff;" color="#0000ff">ASP.NET v4.0</span><span style="color: #000000;" color="#000000">"</span> <span style="color: #ff0000;" color="#ff0000">autoStart</span>=<span style="color: #000000;" color="#000000">"</span><span style="color: #0000ff;" color="#0000ff">true</span><span style="color: #000000;" color="#000000">"</span> <span style="color: #ff0000;" color="#ff0000">managedRuntimeVersion</span>=<span style="color: #000000;" color="#000000">"</span><span style="color: #0000ff;" color="#0000ff">v4.0</span><span style="color: #000000;" color="#000000">"</span> <span style="color: #ff0000;" color="#ff0000">managedPipelineMode</span>=<span style="color: #000000;" color="#000000">"</span><span style="color: #0000ff;" color="#0000ff">Integrated</span><span style="color: #000000;" color="#000000">"</span><span style="color: #0000ff;" color="#0000ff">&gt;</span><br /> <span style="margin-left: 40px;"><span style="color: #0000ff;" color="#0000ff">&lt;</span><span style="color: #800000;" color="#800000">processModel</span> <span style="color: #ff0000;" color="#ff0000">identityType</span>=<span style="color: #000000;" color="#000000">"</span><span style="color: #0000ff;" color="#0000ff">ApplicationPoolIdentity</span><span style="color: #000000;" color="#000000">"</span> <b><span style="color: #ff0000;" color="#ff0000">loadUserProfile</span>=<span style="color: #000000;" color="#000000">"</span><span style="color: #0000ff;" color="#0000ff">true</span><span style="color: #000000;" color="#000000">"</span> <span style="color: #ff0000;" color="#ff0000">setProfileEnvironment</span>=<span style="color: #000000;" color="#000000">"</span><span style="color: #0000ff;" color="#0000ff">true</span><span style="color: #000000;" color="#000000">"</span></b> <span style="color: #0000ff;" color="#0000ff">/&gt;</span></span><br /> <span style="color: #0000ff;" color="#0000ff">&lt;/</span><span style="color: #800000;" color="#800000">add</span><span style="color: #0000ff;" color="#0000ff">&gt;</span> </span></p>
<p>Having completed that we restart the Application Pool to make sure the new settings are applied and run our Web Application again. If everything went as expected we should be ... faced by a new error:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/4278.1.0_AspNetFailure2.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/4278.1.0_5F00_AspNetFailure2.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_12_2D00_08/4278.1.0_AspNetFailure2.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_12_2D00_08/4278.1.0_5F00_AspNetFailure2.png" /></a></p>
<p>There's no reason to panic, as this error is fully expected. After all we haven't dealt with the second problem with running LocalDB under full IIS. We still need to address the fact that by default LocalDB instances are private, which means that IIS, running as ApplicationPoolIdentity, will not have access to our LocalDB instance, running as our Windows account. We will explore different ways to address this problem in the <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-2-instance-ownership.aspx">second post</a> from this mini-series on using LocalDB under full IIS.</p>
<p>- Krzysztof Kozielczyk</p>
<h3>Share Your Feedback</h3>
<p>Please share your feedback with us! Just start a thread on <a href="https://social.msdn.microsoft.com/Forums/sqlexpress/">SQL Express Forum</a>, hit the "Email Author" button on this post, or file a <a href="https://connect.microsoft.com/SQLServer">Connect</a> item!</p>]]></content:encoded>
    </item>
    <item>
      <title>Announcing SQL Server 2012 Express LocalDB RC0</title>
      <link>https://docs.microsoft.com/archive/blogs/sqlexpress/announcing-sql-server-2012-express-localdb-rc0</link>
      <pubDate>Mon, 28 Nov 2011 01:29:00 GMT</pubDate>
      <dc:creator><![CDATA[sqlexpress]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sqlexpress/2011/11/28/announcing-sql-server-2012-express-localdb-rc0/</guid>
      <description><![CDATA[LocalDB RC0 is Here, with a Brand New MSI!Release Candidate 0 for SQL Server 2012 has just...]]></description>
      <content:encoded><![CDATA[<h3>LocalDB RC0 is Here, with a Brand New MSI!Release Candidate 0 for SQL Server 2012 has just shipped,&nbsp;bringing a new update to SQL Server Express LocalDB!

As <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx">announced here</a> LocalDB is a version of SQL Server Express, introduced in the CTP3 of SQL Server 2012 and created specifically for developers. It is very easy to install and requires no management, yet it offers the same T-SQL language, programming surface and client-side providers as the regular SQL Server Express. For more details please see the <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx">original announcement</a> and related posts listed in the <a href="https://blogs.msdn.com#TryItNow">Try It Now</a> section below.

With this introduction done I am very happy to present a small, streamlined installer for LocalDB. This dedicated, 33MB MSI package can install LocalDB in 30 seconds and completes the first version of SQL Server Express LocalDB.</p><h3>Installation</h3><p>You can download LocalDB from <a href="https://www.microsoft.com/betaexperience/pd/SQLEXPCTAV2/enus/default.aspx">this page</a>. Just pick your CPU architecture (32-bit or 64-bit) and select <b>LocalDB</b> from the drop-down list. Just double-click the <b>SqlLocalDB.msi</b> file is downloaded that will be downloaded. We kept LocalDB simple so there is not a single configuration option in the entire installer. All you need to do is to accept the EULA and click <b>Next</b> a couple times. The installation of LocalDB requires administrative privileges, so if your machine has UAC enabled you will also need to agree to elevate the installation process.</p><h3>Silent and Embedded Installation</h3><p>As any decent installer, LocalDB supports silent installation. Here is an example a command that installs LocalDB silently:</p><p style="margin: 20px;"><span style="font-family: Consolas; color: #000000;" face="Consolas" color="#000000">msiexec /i SqlLocalDB.msi /qn IACCEPTSQLLOCALDBLICENSETERMS=YES</span>

As you can see these are all standard Windows Installer options, except for the <b>IACCEPTSQLLOCALDBLICENSETERMS</b> variable. Setting it to <b>YES</b> is telling us that the user read and accepted LocalDB EULA. As expected the installer will not continue unless this variable is set to <b>YES</b>.

If you are considering distributing LocalDB with your application, be sure to put 32-bit and 64-bit versions into separate folders. LocalDB doesn't support installing 32-bit version on 64-bit Windows, so you will need to distribute both versions of LocalDB with your application and they both have the same file name (<b>SqlLocalDB.msi</b>). Renaming LocalDB packages is not an option, as Windows Installer requires that MSI file names don't change (see <b>Rule 14</b> in <a href="https://blogs.msdn.com/b/windows_installer_team/archive/2006/05/12/595950.aspx">this post</a> for the explanation).</p><h3>Multiple Versions of LocalDB and Upgrades</h3><p>To keep the LocalDB installation simple we decided that major versions of LocalDB will be installed side-by-side. This way an application using LocalDB version 11 will never be broken by some other application upgrading LocalDB to version 12. Both applications will be able to install the versions of LocalDB they need without interfering with each other.

Service Packs for LocalDB will also work in the simplest possible way. In each Service Pack we will release new MSI packages containing all the LocalDB binaries. The updated MSI package can be used to either apply the Service Pack to an existing LocalDB installation or to install a fresh LocalDB installation. In both cases the command line for the silent installation will be the same.</p><h3><a name="TryItNow"></a>Try It Now!</h3><p>As you can tell we are fairly satisfied with the final shape of LocalDB, at least for SQL Server 2012. But the final call belongs to you! Please give it a try and share your feedback with us.

You may also want to see other posts and materials about LocalDB:</p><ul>  <li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx">Introducing LocalDB and LocalDB Q&amp;A</a></li>  <li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/27/net-framework-4-now-supports-localdb.aspx">Upgrading .NET Framework 4 to support LocalDB connections and using SQL Server Management Studio to work with LocalDB</a></li>  <li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/11/28/using-localdb-in-visual-studio-2010.aspx">Using LocalDB in Visual Studio 2010</a></li>  <li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/11/28/simple-installer-for-localdb-has-shipped.aspx">LocalDB RC0 and the New LocalDB Installer</a></li>  <li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/28/localdb-where-is-my-database.aspx">Where are LocalDB database files located?</a></li>  <li><a href="https://msdn.microsoft.com/en-us/library/hh510202(v=sql.110).aspx">SQL Server 2012 Express LocalDB documentation [preview]</a></li>  </ul><p>- Krzysztof Kozielczyk

<p></p><h3>Share Your Feedback</h3><p>Please share your feedback with us! Just start a thread on <a href="https://social.msdn.microsoft.com/Forums/sqlexpress/">SQL Express Forum</a>, hit the "Email Author" button on this post or file a <a href="https://connect.microsoft.com/SQLServer">Connect</a> item!</p></h3>]]></content:encoded>
    </item>
    <item>
      <title>Using LocalDB in Visual Studio 2010</title>
      <link>https://docs.microsoft.com/archive/blogs/sqlexpress/using-localdb-in-visual-studio-2010</link>
      <pubDate>Sun, 27 Nov 2011 23:41:00 GMT</pubDate>
      <dc:creator><![CDATA[sqlexpress]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sqlexpress/2011/11/27/using-localdb-in-visual-studio-2010/</guid>
      <description><![CDATA[SSMS is a Success, But What About&nbsp;the VS?
In&nbsp;my recent post I was using .NET Framework...]]></description>
      <content:encoded><![CDATA[<h3>SSMS is a Success, But What About&nbsp;the VS?</h3>
<p>In&nbsp;my <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/27/net-framework-4-now-supports-localdb.aspx">recent post</a> I was using .NET Framework 4.0.2 to enable SQL&nbsp;Server Management Studio to connect to LocalDB. It all worked rather&nbsp;well and I declared success and moved on to <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/28/localdb-where-is-my-database.aspx">another topic</a>. I conveniently kept silent about connecting to LocalDB from Visual Studio 2010. For a good reason -- currently Visual Studio 2010 doesn't really work with LocalDB. There are two reasons for that:</p>
<ul>
<li>The SQL Server database experiences in Visual Studio 2010 are built on top of User Instances of SQL Server Express. Using LocalDB to power them is more complex than just changing a connection string to (localdb)\v11.0. It would require releasing some kind of a wide patch for Visual Studio 2010.</li>
<li>LocalDB was introduced in SQL Server 2012 CTP3. Visual Studio 2010 only supports SQL Server 2008 R2 and earlier.</li>
</ul>
<p>In effect, even though adding the connection to LocalDB to <b>Data Connections</b> node of <b>Server Explorer</b> will succeed, trying to open any database designer from this connection will result in this sad message:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/8508.1.0_SqlVersionError.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/8508.1.0_5F00_SqlVersionError.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/8508.1.0_SqlVersionError.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/8508.1.0_5F00_SqlVersionError.png" /></a></p>
<h3>Is There At Least a Hack?</h3>
<p>At this point the situation might seem pretty grim. Without Visual Studio 2010 support for LocalDB, developers that want to try it would need to wait for the next Visual Studio release. How can we get your feedback on LocalDB if there's no way to try it for months?</p>
<p>Fortunately, many Visual Studio 2010 features actually work with LocalDB and we should be able to use SQL Server Management Studio for the missing parts. We could also take the opportunity to try the new <a href="https://blogs.msdn.com/b/ssdt/archive/2011/11/21/download-available-sql-server-data-tools-ctp4-ssdt.aspx">SQL Server Data Tools</a> -- I will post about working with LocalDB from SSDT soon, as it integrates into Visual Studio, providing developers with a nice alternative for usig SSMS.</p>
<p>I already covered <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/27/net-framework-4-now-supports-localdb.aspx">how to connect to LocalDB from SSMS</a> and create databases, tables, input data and so on. Let's look at how we can use them from the Visual Studio 2010.</p>
<p>As I mentioned earlier creating a connection to LocalDB in the <b>Data Connections</b> node of <b>Server Explorer</b> will just work. Let's give it a try! One way to do it is to right-click the <b>Data Connections</b> node and select <b>Add Connection...</b></p>
<p><b><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/3465.2.1_AddConnection.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/3465.2.1_5F00_AddConnection.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/3465.2.1_AddConnection.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/3465.2.1_5F00_AddConnection.png" /></a></b></p>
<p>We should use the standard LocalDB connection string: <b>(localdb)\v11.0</b></p>
<p><b><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/0576.2.2_DatabaseConnectionProperties.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/0576.2.2_5F00_DatabaseConnectionProperties.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/0576.2.2_DatabaseConnectionProperties.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/0576.2.2_5F00_DatabaseConnectionProperties.png" /></a></b></p>
<p>Clicking <b>OK</b> and done, the connection is created!</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/0172.2.3_DatabaseConnectionCreated.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/0172.2.3_5F00_DatabaseConnectionCreated.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/0172.2.3_DatabaseConnectionCreated.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/0172.2.3_5F00_DatabaseConnectionCreated.png" /></a></p>
<p>Don't worry about the strange format of the connection -- we will soon see that the connection indeed points to our usual LocalDB instance.</p>
<p>The next step is to use the connection. Let's create a <b>DataGridView</b> control by dragging it from the <b>Toolbox</b> panel.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/8561.2.5_DbGridConnection.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/8561.2.5_5F00_DbGridConnection.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/8561.2.5_DbGridConnection.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/8561.2.5_5F00_DbGridConnection.png" /></a></p>
<p>As we can see the <b>DataGridView</b> is not&nbsp;connected to any data source. Let's bind it to our LocalDB connection. Click <b>Add Project Data Source...</b> link on the <b>Tasks</b> quickview of the <b>DataGridView</b> control to bring up the data connection wizard and select <b>Database</b> and <b>Dataset</b> on the next two screens.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/0412.2.6_DbGridConnection1.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/0412.2.6_5F00_DbGridConnection1.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/0412.2.6_DbGridConnection1.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/0412.2.6_5F00_DbGridConnection1.png" /></a></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/2063.2.7_DbGridConnection2.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/2063.2.7_5F00_DbGridConnection2.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/2063.2.7_DbGridConnection2.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/2063.2.7_5F00_DbGridConnection2.png" /></a></p>
<p>When asked about the connection, pick the LocalDB connection from the list. Once it's selected we can confirm that it points to LocalDB by looking at the <b>Connection string</b> property.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/4237.2.8_DbGridConnectionString.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/4237.2.8_5F00_DbGridConnectionString.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/4237.2.8_DbGridConnectionString.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/4237.2.8_5F00_DbGridConnectionString.png" /></a></p>
<p>The last step is selecting a table to be presented in the <b>DataGridView</b>. After finishing the wizard the <b>DataGridView</b> should have the same columns as the underlying table, like this:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/5165.2.A_DbGridReady.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/5165.2.A_5F00_DbGridReady.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/5165.2.A_DbGridReady.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/5165.2.A_5F00_DbGridReady.png" /></a></p>
<p>We're done. Hold your breath and hit F5 to run the application. With any luck it should start and the <b>DataGridView</b> should present the data from the table, like on this screenshot:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/8308.2.B_DbGridRunning.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/8308.2.B_5F00_DbGridRunning.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_27/8308.2.B_DbGridRunning.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_27/8308.2.B_5F00_DbGridRunning.png" /></a></p>
<p>That was easy, wasn't it? :-)</p>
<h3>Try It Now!</h3>
<p>This walkthrough covers just one scenario, but the same approach should work in other scenarios as well. Just use SSMS or SSDT to create your database and Visual Studio to connect to it. Please try out your favorite scenario and share your feedback!</p>
<p>You may also want to see other posts and materials about LocalDB:</p>
<ul>
<li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx">Introducing LocalDB and LocalDB Q&amp;A</a></li>
<li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/27/net-framework-4-now-supports-localdb.aspx">Upgrading .NET Framework 4 to support LocalDB connections and using SQL Server Management Studio to work with LocalDB</a></li>
<li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/11/28/using-localdb-in-visual-studio-2010.aspx">Using LocalDB in Visual Studio 2010</a></li>
<li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/11/28/simple-installer-for-localdb-has-shipped.aspx">LocalDB RC0 and the New LocalDB Installer</a></li>
<li><a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/28/localdb-where-is-my-database.aspx">Where are LocalDB database files located?</a></li>
<li><a href="https://msdn.microsoft.com/en-us/library/hh510202(v=sql.110).aspx">SQL Server 2012 Express LocalDB documentation [preview]</a></li>
</ul>
<p>- Krzysztof Kozielczyk</p>
<p></p>
<h3>Share Your Feedback</h3>
<p>Please share your feedback with us! Just start a thread on <a href="https://social.msdn.microsoft.com/Forums/sqlexpress/">SQL Express Forum</a>, hit the "Email Author" button on this post or file a <a href="https://connect.microsoft.com/SQLServer">Connect</a> item!</p>]]></content:encoded>
    </item>
    <item>
      <title>LocalDB: Where is My Database?</title>
      <link>https://docs.microsoft.com/archive/blogs/sqlexpress/localdb-where-is-my-database</link>
      <pubDate>Fri, 28 Oct 2011 14:11:00 GMT</pubDate>
      <dc:creator><![CDATA[sqlexpress]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sqlexpress/2011/10/28/localdb-where-is-my-database/</guid>
      <description><![CDATA[As I mentioned in the previous post LocalDB handles database files differently than regular SQL...]]></description>
      <content:encoded><![CDATA[<p>As I mentioned in the <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/27/net-framework-4-now-supports-localdb.aspx">previous post</a> LocalDB handles database files differently than regular SQL Server.</p>
<p>The regular SQL Server assumes that it is actively managed by a DBA. The DBA carefully configures SQL Server during the installation and afterwards. The DBA decides where SQL Server binaries are installed. The DBA also decides where the system database files are located. The location of the system databases also becomes the default location for all user databases.</p>
<p>LocalDB is different. It's built to be used by developers, not DBAs. And we have heard developers saying loud and clear that they just want to focus on their databases and database code. Therefore our primary design goal was to eliminate all the server configuration and management that is getting in their way. As a result LocalDB stores all the system databases deep inside the "hidden" <b>AppData</b> folder in the user profile. For example, after playing with the Automatic Instance in the <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/27/net-framework-4-now-supports-localdb.aspx">previous post</a>, I find this folder in my user profile:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_11/2146.1_SystemDatabases.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_11/2146.1_5F00_SystemDatabases.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_11_2D00_11/2146.1_SystemDatabases.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_11_2D00_11/2146.1_5F00_SystemDatabases.png" /></a></p>
<p>This folder constitutes my Automatic LocalDB Instance. Any good DBA will explain in great and painful details what these files are, but if you are a developer this is the first and the last time you will look at them. Which is great, but left us with an interesting question. If the location of system databases is hidden from the developer, what should the default location for the databases created by the developer be? Creating user databases in a hidden folder didn't seem like the right design. We considered <b>My Documents</b> too, but that could give the impression that SQL Server databases are portable documents. Plus half of our team was using some sort of document synchronization solution, like Live Mesh. Those would quickly destroy the database files and we thought they will only get more popular over time, thus more likely to wreck havoc in the future.</p>
<p>In the end we decided to create the database files in the root of the user profile. On most machines it is located in <b>C:\Users\<i>user-name</i></b> folder</p>
<p>In the spirit of a scientific approach, let's try it out. Open SSMS and connect to your Automatic Instance:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/4604.1.0_ConnectToDialog.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/4604.1.0_5F00_ConnectToDialog.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/4604.1.0_ConnectToDialog.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/4604.1.0_5F00_ConnectToDialog.png" /></a></p>
<p>Then create database <b>foo</b> without specifying the location for its files:</p>
<p style="margin: 20px;"><span style="font-family: Consolas; color: #0000ff;" face="Consolas" color="#0000ff">create database <span style="color: #008080;" color="#008080">foo</span></span></p>
<p>Open Windows Explorer and navigate to your profile (typing <b>%USERPROFILE%</b> in the address bar is a nice shortcut). If the database was created successfully there will be new files in this folder, <b>foo.mdf</b> and <b>foo_log.ldf</b> that represent your database. QED.</p>
<p>Given that user profile folder is likely <b>not</b> the best location to store database files, we advise developers creating databases to always specify the location for the database files, like in this T-SQL example:</p>
<p style="margin: 20px;"><span style="font-family: Consolas; color: #0000ff;" face="Consolas" color="#0000ff">create database <span style="color: #008080;" color="#008080">foo</span> on (name=<span style="color: #ff0000;" color="#ff0000">'foo'</span>, filename=<span style="color: #ff0000;" color="#ff0000">'c:\DBs\foo.mdf'</span>)</span></p>
<p>- Krzysztof Kozielczyk</p>
<p></p>
<h3>Send us Your Feedback</h3>
<p>Please share your feedback with us! Just start a thread on <a href="https://social.msdn.microsoft.com/Forums/sqlexpress/">SQL Express Forum</a>, hit the "Email Author" button on this post or file a <a href="https://connect.microsoft.com/SQLServer">Connect</a> item!</p>]]></content:encoded>
    </item>
    <item>
      <title>.NET Framework 4 now supports LocalDB!</title>
      <link>https://docs.microsoft.com/archive/blogs/sqlexpress/net-framework-4-now-supports-localdb</link>
      <pubDate>Thu, 27 Oct 2011 19:35:00 GMT</pubDate>
      <dc:creator><![CDATA[sqlexpress]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sqlexpress/2011/10/27/net-framework-4-now-supports-localdb/</guid>
      <description><![CDATA[Updated 2011-11-11: Added a link to the post on how LocalDB handles database file...]]></description>
      <content:encoded><![CDATA[<p>Updated 2011-11-11: Added a link to the post on how LocalDB handles database file locations.</p>
<p>Updated 2012-01-03: Clarified that only SSMS from SQL Server 2012 (or newer) will work with the .NET 4 Update 4.0.2, since earlier SSMS versions are using .NET 3.5.</p>
<h3>.NET Framework 4 Update 4.0.2</h3>
<p>.NET team has just released Update 4.0.2 for .NET Framework 4. This update enables connecting to SQL Server Express LocalDB via System.Data.SqlClient provider.</p>
<p>.NET Framework 4 Update 4.0.2 can be downloaded from <a href="https://support.microsoft.com/kb/2544514">https://support.microsoft.com/kb/2544514</a></p>
<h3>Does this work?</h3>
<p>Well, let's give it a try!</p>
<p>We start by installing SQL Server 2012 Management Studio RC0 (SSMS) and LocalDB together with .NET 4. The version of SSMS is important as earlier versions are using .NET 3.5 and currently only .NET 4 can be updated to understand LocalDB connection strings. Next we update .NET 4 to 4.0.2 (hey, no reboot in my case!). Then fire up SSMS. When prompted for the server address we specify "<b>(localdb)\v11.0</b>", like this:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/4604.1.0_ConnectToDialog.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/4604.1.0_5F00_ConnectToDialog.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/4604.1.0_ConnectToDialog.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/4604.1.0_5F00_ConnectToDialog.png" /></a></p>
<p>Clicking <b>Connect</b> and &hellip; (drum roll please!) &hellip;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/8623.1.2_Connected.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/8623.1.2_5F00_Connected.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/8623.1.2_Connected.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/8623.1.2_5F00_Connected.png" /></a></p>
<p>Success!</p>
<h3>Does it really work?</h3>
<p>OK, so we confirmed SSMS connects to LocalDB. Which is great, but how about doing something more useful for a developer? The next logical step would be to create a database. We know the drill -- right-click the <b>Databases</b> node in <b>Object Explorer</b> and select <b>New Database</b>. So far, so good. After typing in the name of the new database (in my case <b>LocalDBTest</b>) we are ready to hit OK...</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/3276.2.0_CreateDBDialog.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/3276.2.0_5F00_CreateDBDialog.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/3276.2.0_CreateDBDialog.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/3276.2.0_5F00_CreateDBDialog.png" /></a></p>
<p>Clicking <b>OK</b> and ... we hit an error!</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/8420.2.1_CreateDBError.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/8420.2.1_5F00_CreateDBError.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/8420.2.1_CreateDBError.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/8420.2.1_5F00_CreateDBError.png" /></a></p>
<p>This is obviously a bug, but there are at least two reasons we shouldn't panic. First, the bug has an easy workaround that we're going to use very, very soon. Second, it points to an important characteristic of the way LocalDB handles database files. I will explain it in more detail in the <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/28/localdb-where-is-my-database.aspx">next post</a>, but for now let's get back to LocalDB and creating our database.</p>
<p>To work around this problem we need to explicitly specify the folder for the database files. For the lack of a better location let's just put them into <b>My Documents</b>, like this:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/4011.2.2_CreateDBCorrectFiles.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/4011.2.2_5F00_CreateDBCorrectFiles.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/4011.2.2_CreateDBCorrectFiles.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/4011.2.2_5F00_CreateDBCorrectFiles.png" /></a></p>
<p>This time clicking <b>OK</b> creates the database without any problems.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/4278.2.3_DBCreated.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/4278.2.3_5F00_DBCreated.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/37/92/2011_2D00_10_2D00_27/4278.2.3_DBCreated.png" original-url="https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-37-92-2011_2D00_10_2D00_27/4278.2.3_5F00_DBCreated.png" /></a></p>
<p>We are now ready for some serious database development, but this too will have to wait for another post.</p>
<p>- Krzysztof Kozielczyk</p>
<p></p>
<h3>Send us Your Feedback</h3>
<p>Please share your feedback with us! Feel free to start a thread on <a href="https://social.msdn.microsoft.com/Forums/sqlexpress/">SQL Express Forum</a>, hit the "Email Author" button on this post or file a <a href="https://connect.microsoft.com/SQLServer">Connect</a> item!</p>]]></content:encoded>
    </item>
    <item>
      <title>Introducing LocalDB, an improved SQL Express</title>
      <link>https://docs.microsoft.com/archive/blogs/sqlexpress/introducing-localdb-an-improved-sql-express</link>
      <pubDate>Tue, 12 Jul 2011 05:30:00 GMT</pubDate>
      <dc:creator><![CDATA[sqlexpress]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sqlexpress/2011/07/12/introducing-localdb-an-improved-sql-express/</guid>
      <description><![CDATA[Updated 2011-11-28: Added reference to the walkthrough of using LocalDB in Visual Studio 2010 and to...]]></description>
      <content:encoded><![CDATA[Updated 2011-11-28: Added reference to the walkthrough of <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/11/28/using-localdb-in-visual-studio-2010.aspx">using LocalDB in Visual Studio 2010</a> and to the new <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/11/28/simple-installer-for-localdb-has-shipped.aspx">LocalDB Installer</a>.

Updated 2011-11-02: Added reference to <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/27/net-framework-4-now-supports-localdb.aspx">.NET Framework 4 support for LocalDB</a> in the Q&amp;A section.

<h3>Introduction</h3>

It gives me great pleasure to introduce a new version of SQL Express called SQL Express LocalDB.

LocalDB is created specifically for developers. It is very easy to install and requires no management, yet it offers the same T-SQL language, programming surface and client-side providers as the regular SQL Server Express. In effect the developers that target SQL Server no longer have to install and manage a full instance of SQL Server Express on their laptops and other development machines. Moreover, if the simplicity (and limitations) of LocalDB fit the needs of the target application environment, developers can continue using it in production, as LocalDB makes a pretty good embedded database too.

<h3>Background</h3>

Before focusing on technical description of LocalDB, I'd like to provide some background on the direction we took building it.

Today SQL Server Express serves two distinct needs. On one hand it is a free edition of SQL Server. The installation, management and programming of SQL Express in this role is expected to be 100% compatible with other editions. It can be used for learning, training and to run relatively small production database (with less than 10GB of data). Upgrade from SQL Express to paid SQL Server editions is a matter of typing in a license key and no installation is required.

But SQL Express is also SQL Server edition for developers writing applications targeting SQL Server. In this role the programming of SQL Express is still expected to be 100% compatible with other SQL Server editions, but SQL Express is supposed to be small, simple, low-footprint, require no configuration or administration, run as non-admin user, etc.

Our approach so far was to try to make SQL Express perform well in both roles. But as SQL Server product matured, and in effect added more complexity, it became harder and harder for SQL Express to be both compatible with other SQL Server editions and small/simple. The challenge is most visible in installation and configuration of SQL Express. In SQL Server "Denali" we decided to change the approach it and introduce a dedicated version of SQL Express for developers - LocalDB that delivers the simplicity and yet is compatible with other editions of SQL Server at the API level.

Also, by making LocalDB a better SQL Express for developers, we hope to be able to improve the regular SQL Express to be a better free SQL Server. We'd be very happy to hear your feedback in this area, especially if you're using SQL Express as a database server and find any issues caused by the new features that were introduced to fit the needs of developers and desktop environment.

<h3>High-Level Overview</h3>

After the lengthy introduction it's time to take a look at LocalDB from the technical side. At a very high level, LocalDB has the following key properties:

<ol>  <li>LocalDB uses the same sqlservr.exe as the regular SQL Express and other editions of SQL Server. The application is using the same client-side providers (ADO.NET, ODBC, PDO and others) to connect to it and operates on data using the same T-SQL language as provided by SQL Express.</li>  <li>LocalDB is installed once on a machine (per major SQL Server version). Multiple applications can start multiple LocalDB processes, but they are all started from the same sqlservr.exe executable file from the same disk location.</li>  <li>LocalDB doesn't create any database services; LocalDB processes are started and stopped automatically when needed. The application is just connecting to "Data Source=(localdb)\v11.0" and LocalDB process is started as a child process of the application. A few minutes after the last connection to this process is closed the process shuts down.</li>  <li>LocalDB connections support AttachDbFileName property, which allows developers to specify a database file location. LocalDB will attach the specified database file and the connection will be made to it.</li>  </ol>

<h3>LocalDB Instances</h3>

As we said before, at the heart of LocalDB is the same sqlservr.exe as in the regular SQL Express and other editions of SQL Server. In case of LocalDB, it is installed into one central location together with all necessary DLLs. By default it is located at "C:\Program Files\Microsoft SQL Server\110\LocalDB\Binn".

When an application uses any of the client-side providers (like ADO.NET, ODBC or PDO) to connect to "Data Source=(localdb)\v11.0", the provider will first check if LocalDB instance for the current user is started. If it's already started the application will connect to it. Otherwise the LocalDB instance for the current user will be started and then the provider proceeds to connect to it. Note that each user (Windows login) may have their own LocalDB instance that is isolated from instances of other users.

To try LocalDB just use this connection string: "Data Source=(localdb)\v11.0;Integrated Security=true". Note that because the activation logic lives in the client-side provider, you need to install the latest one - SQL Server Native Client "Denali" (for ODBC and OLE DB) or the next .NET Framework (for ADO.NET). We are also shipping a QFE for .NET Framework 4 that adds the support for LocalDB to it (the updated .NET Framework 4 is already available, see <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/27/net-framework-4-now-supports-localdb.aspx">this post</a> for details).

<h3>Database as a File</h3>

LocalDB connection strings support AttachDbFileName property that allows attaching a database file during the connection process. This lets developers work directly with databases instead of the database server. Assuming a database file (*.MDF file with the corresponding *.LDF file) is stored at "C:\MyData\Database1.mdf" the developer can start working with it by simply using the following connection string: "Data Source=(localdb)\v11.0;Integrated Security=true;AttachDbFileName=C:\MyData\Database1.mdf".

<h3>New Installer</h3>

In this CTP LocalDB is a shared feature of SQL Server Express available to try as an option during installation of any other version of SQL Express. Our ultimate goal is to offer LocalDB in a separate, simplified and smaller installer. We will keep you posted on our progress here.

<h3>LocalDB and User Instances of SQL Express</h3>

Users familiar with today's User Instances of SQL Server Express should feel right at home with LocalDB. In essence LocalDB offers the ability to create and start a "user instance" without the hassle of installing and maintaining the parent SQL Express instance. In that respect LocalDB could be seen as an upgrade of the User Instances feature of SQL Server Express.

Let me also take this opportunity to remind everyone that User Instances are on a deprecation path since SQL Server 2008.

<h3>LocalDB and SQL Express</h3>

LocalDB is not a replacement for SQL Server Express -- it is an addition to SQL Server Express lineup. While LocalDB is meant for developers, the regular SQL Server Express will continue to exist as a free SQL Server edition, fully compatible with and easily upgradeable to higher SQL Server editions.

<h3>LocalDB and SQL Server Compact?</h3>

Small and simple database, lightweight installation, connecting to a database file -- this will sound familiar to any developer using SQL Server Compact. The similarities are not accidental, as our goal for LocalDB was to be as easy to use as SQL Server Compact (while being as powerful and compatible with full SQL Server as SQL Express).

There are significant differences between LocalDB and SQL Server Compact:

<ol>  <li>Execution mode: SQL Server Compact is an in-proc DLL, while LocalDB runs as a separate process.</li>  <li>Disk usage: all SQL Server Compact binaries amount to some 4MBs, while LocalDB installation takes 140MBs.</li>  <li>Features: SQL Server Compact offers core RDBMS functionality like querying, while LocalDB provides a much richer set of features, including Stored Procedures, Geometry and Geography data types, etc.</li>  </ol>

<h3>Send us Your Feedback</h3>

Please share your feedback with us! Feel free to start a thread on <a href="https://social.msdn.microsoft.com/Forums/sqlexpress/">SQL Express Forum</a>, hit the "Email Author" button on this post or file a <a href="https://connect.microsoft.com/SQLServer">Connect</a> item!

&nbsp;

&nbsp;

<h3>Q&amp;A</h3>

Thank you all for your feedback. Please read below for answers to your questions!

&nbsp;

Q: You say that LocalDB runs as a separate process. However, the main SQL Server site states "LocalDB has all of the same programmability features as SQL Express, but runs in-process with applications". So which is it?

A: LocalDB runs as a separate process - it does not run in-process. It does&nbsp;however run in the same security context as the calling application.

&nbsp;

Q: Does SQL Express Denali still have the same memory limitations as that of SQL Server 2005 Express.

A: The memory limitation has not changed for Denali. At Denali RTM, LocalDB will have the same memory limitations as Express.

&nbsp;

Q: What is the difference between LocalDB and SQL Server Compact Edition?

A: LocalDB is&nbsp;the SQL Server database engine. As such it offers functionality&nbsp;such as&nbsp;online backup, transactions and data integrity.&nbsp; LocalDB is designed for PCs but unlike Compact does not support small mobile devices like smart phones because of its hardware and disk requirements. Compact Edition is a shared file system database.&nbsp; It is not fully API compatible with SQL Server and does not support the same level of data integrity. SQL Compact is also not supported by the PHP Driver and PDO.

&nbsp;

Q: Where can I find the option to install LocalDB?

<span style="text-decoration: line-through;">A: You must install the SQL Server Express Edition and select LocalDB as a feature. You can unselect the Database Engine if you do not require SQL Server Express as a service.</span>

A: Starting from SQL Server 2012 RC0 LocalDB can be downloaded and installed separately, as described in <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/11/28/simple-installer-for-localdb-has-shipped.aspx">this post</a>.

&nbsp;

Q: How do you actually create a LocalDB database?

A: Connect to LocalDB and then use the usual T-SQL &ldquo;CREATE DATABASE &hellip;&rdquo; command.

&nbsp;

Q: Can LocalDB be a subscriber for merge replication?

A: Merge replication is not supported by LocalDB.

&nbsp;

Q: Can LocalDB be launched from a service?

A: LocalDB can be launched from a service, as long as the profile is loaded for the service account.

&nbsp;

Q: Installed OK, but how about a nice little VS2010 C# (working) sample for creating a LocalDB database?

<span style="text-decoration: line-through;">A: We are currently working on a sample application to illustrate the usage of LocalDB in C#.</span>

A: Please see <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/11/28/using-localdb-in-visual-studio-2010.aspx">Using LocalDB in Visual Studio 2010</a> for a sample walkthrough.

&nbsp;

Q: When will System.Data.SqlClient support LocalDB?

<span style="text-decoration: line-through;">A: LocalDB is planned to be supported with .NET 4.0 with a QFE (not yet shipped) and future versions of .NET</span>

<p>A: LocalDB is supported by System.Data.SqlClient in .NET Framework 4 Update 4.0.2, as announced in <a href="https://blogs.msdn.com/b/sqlexpress/archive/2011/10/27/net-framework-4-now-supports-localdb.aspx">this post</a>.</p>]]></content:encoded>
    </item>
    <item>
      <title>ClickOnce Bootstrapper for SQL Server 2008 R2 Express</title>
      <link>https://docs.microsoft.com/archive/blogs/sqlexpress/clickonce-bootstrapper-for-sql-server-2008-r2-express</link>
      <pubDate>Wed, 30 Mar 2011 13:52:00 GMT</pubDate>
      <dc:creator><![CDATA[sqlexpress]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sqlexpress/2011/03/30/clickonce-bootstrapper-for-sql-server-2008-r2-express/</guid>
      <description><![CDATA[I'd like to share this post about ClickOnce Bootstrapper for SQL Server 2008 R2 Express delivered...]]></description>
      <content:encoded><![CDATA[<p style="FONT-FAMILY: "><span style="font-family: helvetica;"><span style="font-size: small;"><span style="font-family: trebuchet ms,geneva;">I'd like to share this post about ClickOnce Bootstrapper for SQL Server 2008 R2 Express delivered for the community by Robin Shahan (RobinDotNet, MVP). It is great to see members of our community to step up and deliver where we failed to deliver. Thank you Robin!</span></span></span><a href="https://robindotnet.wordpress.com/2011/02/06/how-about-a-bootstrapper-package-for-sqlserver-express-2008-r2/" style="FONT-FAMILY: "><span style="font-family: helvetica;"><span style="font-size: small;"><span style="font-family: verdana,geneva;"><span style="font-size: small;"><span style="font-family: trebuchet ms,geneva;">https://robindotnet.wordpress.com/2011/02/06/how-about-a-bootstrapper-package-for-sqlserver-express-2008-r2/</span></span></span></span></span></a>

<span style="font-family: verdana,geneva;"><span style="font-size: small;"><span style="font-family: trebuchet ms,geneva;">Disclaimer &ndash; this ClickOnce bootstrapper package is not supported by Microsoft. You are using it at your own risk. Any comments, complaints or suggestions should be directed to the author.&nbsp;</span></span></span>

<span style="font-family: verdana,geneva;"><span style="font-size: small;"><span style="font-family: trebuchet ms,geneva;">- Krzysztof Kozielczyk</span></span></span>

<span style="font-family: verdana,geneva;"><span style="font-size: small;"><span style="font-family: trebuchet ms,geneva;"></span></span></span></p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server 2008 R2 Express has been released</title>
      <link>https://docs.microsoft.com/archive/blogs/sqlexpress/sql-server-2008-r2-express-has-been-released</link>
      <pubDate>Sun, 25 Apr 2010 21:25:29 GMT</pubDate>
      <dc:creator><![CDATA[sqlexpress]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sqlexpress/2010/04/25/sql-server-2008-r2-express-has-been-released/</guid>
      <description><![CDATA[The final release of SQL Server 2008 R2 was made publically available on April 21, 2010! SQL Server...]]></description>
      <content:encoded><![CDATA[The final release of <a href="https://www.microsoft.com/sqlserver/2008/en/us/R2.aspx">SQL Server 2008 R2</a> was made publically available on April 21, 2010! SQL Server Express continues to ship in 4 different packages. In this release of Express, we simplified the installation wizard. For the November CTP release, I documented the Express installation process at <a title="https://blogs.msdn.com/petersad/archive/2009/11/13/how-to-install-sql-server-2008-r2-express-edition-november-ctp.aspx" href="https://blogs.msdn.com/petersad/archive/2009/11/13/how-to-install-sql-server-2008-r2-express-edition-november-ctp.aspx">https://blogs.msdn.com/petersad/archive/2009/11/13/how-to-install-sql-server-2008-r2-express-edition-november-ctp.aspx</a>. The installation process has not changed since the November CTP, except some messages have been changed to indicate the final release.<p>I posted more information about this release to <a title="https://blogs.msdn.com/petersad/archive/2010/04/26/installing-sql-server-2008-r2-express.aspx" href="https://blogs.msdn.com/petersad/archive/2010/04/26/installing-sql-server-2008-r2-express.aspx">https://blogs.msdn.com/petersad/archive/2010/04/26/installing-sql-server-2008-r2-express.aspx</a>.</p>]]></content:encoded>
    </item>
  </channel>
</rss>