Wednesday 12 August 2015

How to Use a edmx file for multiple DB having same type of table and schema.

1.There are 3 database are have same type of table for 3 application.


Tables are

2.Another database to manage the applications  having a table to store the Application ID ,server name,DBname,Password and username  of application database.






3. create a Edmx file for a Application that will work as a template and another
 for the DB to manage Application



                                                           (for manage applications)
4.while creating the edmx file the class  generate by edmx file is

5. Create a class of same class name as above with a parameterized constructor to pass the connection string to this for change the Db connection string dynamically .


6. based on the application id we will get the database detail and pass to the function to change the connection string .

 Copy the connection  string for applicationDB from web.config file and put that in a string and change the server name, DBname, Password and username  of application based on Appid.

7.GetuserDBbyAppid() function we will get the entity for the particular DB .then we can use the Entity Framework to curd operation on that DB.
Like

USE of this:
 Need not required to create edmx file for same type of database which are situated in different servers and all server can manage through a application means we can create users in base application so that user can login in assigned application .



thanks ,
Pradeep Kumar Das