Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

Im looking for right way to make a database(Local) that is accessible from more projects in the same solution?
Can anyone tell me how the best way to do this. do i have to make own database project of can i use local database in one of the projects and connect it to the other projects.

Greetings Twan
Posted
Comments
Meysam Toluie 15-May-14 4:36am    
Somehow you reply yourself in the question.
BELGIUMsky 15-May-14 6:37am    
it would be making a Library project where you put all the code for your database connection and then add the library as a reference to the projects that will use it.
gggustafson 15-May-14 12:13pm    
By "database" do you mean a collection of unrelated data or a collection of related data (as in a database like SQL)?

A collection of unrelated data can be collected into a class library in the solution and be accessed by all the projects in the solution.

A database can be inherently shared between projects (same connection string).

Hello,

From what I understand about your question is you want to be able to make database calls the same way to the same db throughout your solution?

If yes, you have 3 options.

1: EF (EntityFramework)
2: DLL as one project, reference and call from others
3: Webservice as one project, reference and call from others

I would go with EF, it's the easiest and I love EF haha

Good luck!
 
Share this answer
 
In case of a MS Access or SQLite, store the database file in a location which can be found and accessed by all of your applications, e.g. %PROGRAMDATA%\YourCompany\YourDatabseFile.ext(with MS SQLServer that's not relevant, as that is a Windows Service).
For "Business Objects" shared by your applciations and stored in the database, create a new "class library project" and refernce it from the other applications.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900