Solved

MVC 5 Separate Database Project and Web Project Connection String?

Posted on 2014-09-27
7
616 Views
Last Modified: 2014-10-03
Q. Why do I still need to include the same Entity connection string the the Web Project web.config which is already used in the Database project's app.config?

Makes me wonder why the Database and Edmx is in a separate project within the same solution.

It seems that referencing the Database and using the following code would eliminate the need.

[Web Project Controller]
ProjectDB.ProjectEntities context = new ProjectDB.ProjectEntities ();
...
0
Comment
Question by:WorknHardr
  • 3
  • 3
7 Comments
 
LVL 78

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 250 total points
ID: 40348242
because they are 2 distinct projects even though they may be in the same solution.
0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 40348247
The database project is just a library. It's configuration is not read unless you read it yourself. The runtime will automatically load the connection string from the main application's configuration file. That is where your connection strings should go for execution.
0
 

Assisted Solution

by:WorknHardr
WorknHardr earned 0 total points
ID: 40348535
Understood, thx...

I have an unusual project request of moving both database and Models folder into a separate project. So I did and of coarse the main project failed to build. I then added Entity and Identity references to the database project. Now the main project build and runs like a normal mvc 5 web site should. Get this, I removed the connection strings from the main project web.config and it runs great. I further tested it with typical Entity/Linq CRUD and it works fantastic. So the only connection strings are in the database projects web.config. Unbelievable!
Below is a link I found:

http://blog.rebuildall.net/2013/10/22/Moving_ASP_NET_Identity_model_into_another_assembly
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 40348676
OK, then maybe this is a feature of Entity Framework--in all of the (non-EF) projects I have worked on, it is as I mentioned above.
0
 

Author Comment

by:WorknHardr
ID: 40349077
Ooops, messed-up. Please don't close so I can reward points...
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 40349123
You can "Request Attention" above.
0
 

Author Closing Comment

by:WorknHardr
ID: 40359000
thx
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now