Skip to content

Entity Framework in .net

Arjun Mourya

Asked Jul 25, 2014, 1:54 AM EDT1 answer
Share
LinkedInX
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

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    so you have two dbs mssql & mysql , couple of questions:
    # do you want to keep two dbs, which doesn't make much sense to me, unless there is strong business need?
    # do you want to migrate data from mysql to mssql? if yes there is utility to do that, it's provided by mysql itself?

    twitter @sumitjolly
    0