Solved

MVC 5 Separate Database Project and Web Project Connection String?

Posted on 2014-09-27
7
622 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 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
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 …
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

929 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

10 Experts available now in Live!

Get 1:1 Help Now