title: Visual Studio Online Unit Test and localDb
body: <p>I have a solution that is built on Visual Studio Online.
  All the unit tests in this solution require a database, I tried to get the build use a test's dedicated localdb (by adding a light mdf file in the test project and use a localdb connection string) but it fail with this error (everything work fine on my desktop) :</p>
  <blockquote>
  <p>System.Data.SqlClient.SqlException: Connection Timeout Expired.  The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement.  This could be because the pre-login handshake failed or the server was unable to respond back in time.  The duration spent while attempting to connect to this server was - [Pre-Login] initialization=29460; handshake=161;  ---&gt; System.ComponentModel.Win32Exception: The wait operation timed out.</p>
  </blockquote>
  <p><strong>EDIT</strong></p>
  <p>The connection string is</p>
  <pre><code>&lt;add name=&quot;TestDb&quot; connectionString=&quot;Data Source=(LocalDb)\v11.0;Initial Catalog=AeroBase;Integrated Security=true;AttachDBFilename=|DataDirectory|\App_Data\AeroBase.mdf&quot; providerName=&quot;System.Data.SqlClient&quot; /&gt; 
  </code></pre>
  <p>I use EF6 code first, repository and unit of work patterns to access it.
  Here is the DbContext :</p>
  <pre><code>public class AeroDataContext : DbContext, IDbContext
  {
  private Guid DataContextId;
  private string _name;
  public string Name { get { return _name; } }
  
  public AeroDataContext(string cnxStringName, string cnxString)
      : base(cnxString)
  {
      this.Database.Log = delegate(String name)
                          {
                             // Debug.WriteLine(name);
                          };
      _name = cnxStringName;
      this.Configuration.LazyLoadingEnabled = false;
      DataContextId = Guid.NewGuid();
      Debug.WriteLine(&quot;AeroDbCreation Id = &quot; + DataContextId.ToString());
  
  
  }
  }
  </code></pre>
  <p>The DbContext is instanciated using a unitOfWorkScope :</p>
  <pre><code>    public class UnitOfWorkFactory : IUnitOfWorkFactory
  {
  
      private string _cnxStringName;
      private string _cnxString;
  
      public UnitOfWorkFactory(string cnxStringName, string cnxString)
      {
          _cnxString = cnxString;
          _cnxStringName = cnxStringName;
      }
  
      public IUnitOfWorkScope GetUnitOfWorkScope(bool disposeAtEndOfContext = true)
      {
  
          return new UnitOfWorkScope(new AeroDataContext(_cnxStringName, _cnxString), disposeAtEndOfContext);
      }
  }
  </code></pre>
  <p>which allows me to do things like this in the test (and in the app)</p>
  <pre><code>       [TestMethod]
      public void DB_Get_LFFE_Airport_By_ICAOInclude_SubType()
      {
          //structuremap container built in the TestInitilized method
          IUnitOfWorkFactory _uowf = container.GetInstance&lt;IUnitOfWorkFactory&gt;();
          using (IUnitOfWorkScope uows = _uowf.GetUnitOfWorkScope(true))
          {
  
              IAirportRepository repo = uows.GetRepository&lt;IAirportRepository&gt;();
              Airport ar = repo.SearchByICAO(&quot;LFFE&quot;).FirstOrDefault();
              AirportValidator.LFFE(ar);
             
          }
      }
  </code></pre>
  <p>Is this scenario even possible? is there any other way to do  that?</p>