title: EntityFramework through Class Library
body: <p>I have a class library called <code>DataManip</code>, a webform project and a winform project.</p>
  
  <p><code>DataManip</code> is a class that will contain all the necessary methods to manipulate the database, including handling migrations and database updates.</p>
  
  <p>The <code>.mdf</code> database is also inside the <code>DataManip</code> project.</p>
  
  <p>The problem that I am having right now, is that when I setup a connection string in the <code>App.config</code> file of <code>DataManip</code>, it doesn't recognize the |DataDirectory| substitution string.</p>
  
  <p>Connection string : </p>
  
  <p><code>&lt;add name="Context" connectionString="Data Source=(LocalDB\v11.0;AttachDbFilename=|DataDirectory|DB\mydatabase.mdf;Integrated Security=True providerName="System.Data.SqlClient" /&gt;</code></p>
  
  <p>Harcoding the path in AttachDbFilename will successfully generate the database, but working with team members make this approach not possible.</p>
  
  <p>The error message that I get when I try to run <code>update-database</code> in <code>DataManip</code> is :</p>
  
  <p><code>A file activation error occured. The physical file name '\DB\mydatabase.mdf' may be incorrect...</code></p>
  
  <p>How can I get the DataDirectory substitution string to work in a class library?</p>