实体框架相关澄清

实体框架相关澄清

本文介绍了实体框架相关澄清的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在开发一个显示各种报告的网站。所以我希望这份报告能够在不同的数据库中运行。因此,我决定使用LINQ / Entity SQL实现Entity Framework。我还为MSSQL创建了.edmx,并成功地在Model中显示了来自Model的值,该值在App_Code文件夹中可用。我希望相同的LINQ和Entity SQL查询适用于MySQL数据库。



我为MySQL DB创建了另一个.edmx模型,并且成功地能够在UI。



以下是我的MS SQL代码:



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
 }









我不应该将任何实体模型对象(即demoModel.demoEntities)名称更改为代码中的MySQL实体模型对象名称。如何实现这一点是我的问题?



我也尝试在web.config中更改连接字符串,但是因为无法从Mysql对象转换为MSSQL对象。

请有人指出我正确的教程链接。





-

Arjun





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

推荐答案

这篇关于实体框架相关澄清的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 14:15