Arjun Mourya

Arjun Mourya

  • NA
  • 5
  • 3.3k

Entity Framework in .net

Jul 25 2014 5:54 AM
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:
 
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

Answers (1)