0

What path should be given to the base file in the project.

I tried it but it does not work:

`  <connectionStrings>
    <add name="connection" connectionString="Data Source=(LocalDb)\v11.0; AttachDbFilename=..\Database.mdf;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
  </connectionStrings>`
ThrNikerX
  • 1
  • 3

1 Answers1

0

You can use |DataDirectory| to get the base of your project.

AttachDbFilename=|DataDirectory|\Database.mdf
Ecordero
  • 61
  • 1
  • 6
  • now i have error: A file activation error occurred. The physical file name '\Database.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. – ThrNikerX Oct 18 '18 at 16:02
  • Its basically saying that Database.mdf doesnt exist in your base of your project. Try looking at this answer, its a lot more detailed than what I can do. https://stackoverflow.com/questions/27730546/how-to-define-datadirectory-for-connectionstring-in-console-application-to-work – Ecordero Oct 18 '18 at 16:11