title: Using LocalDB with Service Fabric
body: <p>I have an Actor that upon receiving a request from a WebAPI project, the Actor queries a table using Entity Framework 6.</p>
  
  <pre><code>using (var context = new MetadataContext())
  {
      var userStorageAccountId = context.Set&lt;UsersToStorageAccounts&gt;()
                                        .Find(userId).StorageAccountId;
  }
  </code></pre>
  
  <p>The DB was successfuly created using the "Add-Migration" .. "Update-Database" commands, and has the following connection string:</p>
  
  <pre><code>@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFileName=C:\Users\xxxx\Metadata.mdf;Connect Timeout=30;Initial Catalog=Metadata;Integrated Security=True;"
  </code></pre>
  
  <p>When I run the fabric service and the actor tries to access the context, I get the following exception:</p>
  
  <blockquote>
    <p>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: 50 - Local Database Runtime error occurred. 
        Cannot create an automatic instance. See the Windows Application event log for error details.)</p>
  </blockquote>
  
  <p>and the event viewer error is:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>I looked for a way to load the user's profile, but I only found solutions for IIS.</p>
  
  <p>Please help :)</p>