Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Basically I've created a class library project containing a data access repository for other projects to use. I've added the EF6 package and enabled migrations. My connection string in app.config looks the following:

  <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 occurred. The physical file name '\Pbn.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation. CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

What could be the issue here?

like image 748
JensOlsen112 Avatar asked Nov 12 '14 15:11

JensOlsen112


1 Answers

This is the problem:

AttachDbFilename=|DataDirectory|\Pbn.mdf

That's being interpreted as \Pbn.mdf, and it doesn't exist. This is because you aren't setting the |DataDirectory| value, so it's blank. See here on how to set it.

like image 131
simon at rcl Avatar answered Oct 19 '22 06:10

simon at rcl