Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am developing a website which displays various reports. So I want this report to be working across different databases. Hence I decided go with Entity Framework with LINQ/Entity SQL. I also created .edmx for MSSQL and was successfully able to display values in the UI from Model which is available in App_Code folder. I want the same LINQ and Entity SQL queries to work for MySQL Database.

I created another .edmx model for MySQL DB and also was successfully able to display values in the UI.

Below is my code for MS SQL:

C#
demoModel.demoEntities project = new demoModel.demoEntities();

//MSSQL query
string esqlQuery = @"SELECT tbl.<select_list>  FROM <table_name> AS tbl";

foreach (System.Data.Common.DbDataRecord a in new System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord>(esqlQuery, project))
{ 
//some code here
 }




I should not be changing any Entity Model object( namely demoModel.demoEntities) name to MySQL entity model object name in the code. How to achieve this is my question?

Also I tried changing connection string in the web.config but it was throwing error as "not possible to convert from Mysql object to MSSQL object".
Please someone point me out to right tutorial link.


--
Arjun
Posted

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