Solved

MVC 5 Separate Database Project and Web Project Connection String?

Posted on 2014-09-27
7
673 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 82

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 75

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 75

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 75

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

628 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