Solved

MVC 5 Separate Database Project and Web Project Connection String?

Posted on 2014-09-27
7
626 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 79

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!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

DevOps Toolchain Recommendations

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

Question has a verified solution.

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

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

786 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