Running the update database results in an error: "A file activation error has occurred"

Basically, I created a class library project containing a data access repository for other projects. I added the EF6 package and enabled migrations. The connection string in app.config looks like this:

  <connectionStrings>
    <add name="Pbn" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\Pbn.mdf;Initial Catalog=LM.DataAccess;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>

      

(The project name is LM.DataAccess).

When I run the update-database command, I get the following error:

A file activation error has occurred. The physical file name '\ Pbn.mdf' may not be correct. Diagnose and correct additional errors and retry the operation. CREATE DATABASE failed. Some of the listed filenames may not be generated. Check related errors.

What could be the problem?

+3


source to share


1 answer


This is the problem:

AttachDbFilename=|DataDirectory|\Pbn.mdf

      



This is interpreted as \ Pbn.mdf and does not exist. This is because you are not installing | DataDirectory | value, so it's empty. See here on how to install it.

+4


source







All Articles