Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I want to create one web application in such a way that if tomorrow my new customer have different database . So,with minimal configuration I should connect to it.
E.g.

I created one web application and client using SQL then if another customer approaches with different database like oracle. So, I should provide a layer in such a way that application should work with Oracle and SQL (Not simultaneously ..independently)

I am looking forward with Entity Framework Code First Model where model will create DB in runtime. So, if you guys have any other better way then let me know .
Thanks
Posted

You can use a database-agnostic technology like ADO.net and ODBC, and that way you just change the odbc driver in your connection string and as long as the new database has an adbc driver it *should* just work. There might still be some minor differences in odbc implementation though so you might need to tweak from of the SQL.

Given that is going to adversely impact the performance of your code for a situation that is never going to happen (Microsoft moved away from this type of solution-for-a-problem-noone-has quite some years ago), the next best way would be to abstract your data access code using a data access layer, or a repository patter type solution. When a new data store comes along you'll need to rewrite the data layer for it, but if you've done it correctly that's all you'll need to re-write and you'll be able to use any of your data access layers depending what the client uses. Google repository pattern or data abstraction patterns for more details.
 
Share this answer
 
Entityframework code first approach is the best known way to create such application. You just need to change connection string and done. No need to create tables again.
 
Share this answer
 
Generate script for all table with master data and keep separate. this script you can place in sp into master database with parameter of database name. when you need to create new database then you can run it with your database name parameter.
 
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