0

I'm working on an MVC 3 project, and i created a DAL project too. the EDMX is in the DAL project, and of course there is a connection string in the App.config(in the DAL project) so everytime i want to update the edmx it refers to this connection string of course.

The case is as following, the database is in the APP_Data folder in the MVC 3 project, and so i can update the edmx file, i have to refer to the database using the physical path in the connection string in the App.config in the DAL project. But i want to set the connection string by referring to the APP_DATA folder so it can be more dynamic and so i dont need to change it when i move the project to another location.

so how can i tell the DAL project that the database is in the app_data folder in the MVC project

Thanks

Mahmoud
  • 21
  • 3

1 Answers1

0

You can add the connection string in the web.config of your MVC project instead of App.config of the DAL project.

Simply use |Data Directory| in the connection string to refer the App_Data folder.

Mohayemin
  • 3,841
  • 4
  • 25
  • 54
  • its already there in both config file, just how can the app.config file see the database in the app_data folder in the web project? i cant use "|Data Directory|" because app.config is in a different project, unless there is something i have to do – Mahmoud Aug 05 '12 at 01:19
  • You do not really need the connection string in the DAL project. Just remove that and use `|Data Directory|` and check if it works. – Mohayemin Aug 05 '12 at 17:43
  • yes i know that...mmm...it seems that my question was not really clear, i know at run time the web project reads from the web.config, so i dont really need the app.config at all. just what i'am talking about is at development time, when i want to update the EDMX(the model, and its in the DAL project)it reads the connection string from the app.config and not from the web.config. so how can set the DAL project to access the database that is in Data Directory and without using a physical path Thanks Much :) – Mahmoud Aug 06 '12 at 01:28
  • Oh, I see. I misunderstood your query. – Mohayemin Aug 06 '12 at 03:07