title: Windows Service unable to connect to DB with EF6
body: <p>I developed a Windows Service, using Entity Framework 6.</p>
  
  <p>I run the service, and when it tries to connect to database, it throws the following exception: </p>
  
  <blockquote>
    <p>No connection string named 'testEntities' could be found in the application config file.</p>
  </blockquote>
  
  <p>so i decided to change this code in test.Context.cs</p>
  
  <pre><code>public testEntities()
          : base("name=testEntities")
      {
      }
  </code></pre>
  
  <p>into this:</p>
  
  <pre><code>public testEntities()
          : base("data source=MyLocalServer/sqlexpress;initial catalog=test;persist security info=True;user id=xxxxxx;password=xxxxxxx;MultipleActiveResultSets=True;App=EntityFramework")
      {
      }
  </code></pre>
  
  <p>in practice i changed the name of the entity to the connection string. But it throws the following exception:</p>
  
  <blockquote>
    <p>The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development.  This will not work correctly. To fix this problem do not remove the line of code that throws this exception. </p>
    
    <p>If you wish to use Database First or Model First, then make sure that the Entity Framework connection string is included in the app.config or web.config of the start-up project. If you are creating your own DbConnection, then make sure that it is an EntityConnection and not some other type of DbConnection, and that you pass it to one of the base DbContext constructors that take a DbConnection.</p>
    
    <p>To learn more about Code First, Database First, and Model First see the Entity Framework documentation here: <a href="http://go.microsoft.com/fwlink/?LinkId=394715" rel="nofollow noreferrer">http://go.microsoft.com/fwlink/?LinkId=394715</a></p>
  </blockquote>
  
  <p>in the solution there are 2 projects (including wix for creating installation package). The same error is thrown if i set my project as "StartUp Project"..</p>