Solved

MVC 5 Separate Database Project and Web Project Connection String?

Posted on 2014-09-27
7
637 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 80

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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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