【发布时间】:2015-03-23 11:22:47
【问题描述】:
我是使用 asp.net 使用 MySQL 的新手,我正在尝试使用 asp.net mvc 4 和实体框架 6 来查看来自 MySQL 和 MSSQL 数据库的数据。到目前为止,MSSQL 工作正常。但是每当我尝试从 MySQL 表中查看数据时,我都会收到此错误,
Schema specified is not valid. Errors: Models.MySqlModel.ssdl(2,2) : error
0152: No Entity Framework provider found for the ADO.NET provider with
invariant name 'MySql.Data.MySqlClient'. Make sure the provider is registered
in the 'entityFramework' section of the application config file. See
http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
我已安装 MySQL for Visual Studio 1.1.4 和 MySQL Connector .NET 6.8.3,我已添加 MySql.Data、MySql.Data.Entity.EF5、@ 987654326@ 参考文件夹中的程序集。这是我用于数据库连接的 Web.Config 代码,
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ABCoLtd-20150101142609;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-ABCoLtd-20150101142609.mdf" />
<add name="mytestdbEntities" connectionString="metadata=res://*/Models.SampleModel.csdl|res://*/Models.SampleModel.ssdl|res://*/Models.SampleModel.msl;provider=System.Data.SqlClient;provider connection string="data source=DREAGLEASUS64\SQLEXPRESS;initial catalog=mytestdb;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /><add name="mdsdata_demoEntities" connectionString="metadata=res://*/Models.MySqlModel.csdl|res://*/Models.MySqlModel.ssdl|res://*/Models.MySqlModel.msl;provider=MySql.Data.MySqlClient;provider connection string="server=localhost;user id=root;password=4de570;database=mdsdata_demo"" providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
来自控制器的代码,用于查看 MySQL 表中的数据,
namespace ABCoLtd.Controllers
{
public class HomeController : Controller
{
mytestdbEntities db = new mytestdbEntities(); //MSSQL Model
mdsdata_demoEntities dsedb = new mdsdata_demoEntities(); //MySQL Model
public ActionResult InstrumentList()
{
return View(dsedb.mkistats.ToList()); //The Line showing error
}
}
}
我在这里做错了吗?我非常需要这个帮助。请帮助我,您的帮助将不胜感激。 Tnx。
更新
当我在Reference Manager 中看到它们时,它显示为6.8.3.0,但在Properties 中我得到6.8.4.0。这是可能的错误吗?如果是,解决方案是什么?看下面的图片,
【问题讨论】:
标签: mysql sql-server asp.net-mvc entity-framework