使用MariaDB与实体框架 [英] Using MariaDB with Entity Framework

查看:106
本文介绍了使用MariaDB与实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我看到一则消息称,由于 MySQL不友好,MariaDB是MySQL的替代品根据Google的集群/企业版本定价



现在,我无法在Google上找到与MariaDB有关的任何内容,所以我希望有人知道这一点。可以使用 MySQL驱动程序,因为它是100%兼容?任何想法?



更新



我刚刚发现RedHat也正在从MySQL切换到MariaDB ,因为它是默认的数据库管理系统。所以我目前的项目需要将其转换为MariaDB。

解决方案

我可以使用MariaDB 10与实体框架它需要一些工作,主要是因为MySQL工具有点错误。



在Visual Studio中使用MySQL / MariaDB 2010/2012 ,您需要使用 MySQL for Visual Studio http://dev.mysql.com/downloads/installer/rel =nofollow noreferrer> MySQL安装程序。我使用Web版本,因为我只想下载连接器和扩展。一旦这样做,您可以添加到MariaDB的连接并创建EF模型。



这还不足以运行代码。首先,您需要使用NuGet添加MySQL连接器。



不幸的是,Visual Studio for MySQL添加了对较早提供者版本的引用(提到 here ),无法加载较新版本。要解决这个问题,我在app.config中添加了以下部分:

 < system.data> 
< DbProviderFactories>
< remove invariant =MySql.Data.MySqlClient/>
< add name =MySQL数据提供者invariant =MySql.Data.MySqlClient
description =。用于MySQL的Net Framework数据提供者
type =MySql.Data.MySqlClient .MySqlClientFactory,MySql.Data,Version = 6.7.4.0,Culture = neutral,PublicKeyToken = c5687fc88969c44d/>
< / DbProviderFactories>
< /system.data>

这将替换旧引用。请注意,我使用

 < remove invariant =MySql.Data.MySqlClient/> 

 < remove name =MySql Data Provider/> 

中删除​​元素



目前,Visual Studio 2013不支持MySQL for Visual Studio


Recently, I read a news that MariaDB is a drop-off replacement for MySQL since MySQL has unfriendly pricing for clustered/enterprise version according to Google.

Now I can't find anything relevant about EF for MariaDB on Google so I'm hoping someone knows about it. Is it ok to use MySQL driver for this since it is 100% compatible? Any thoughts?

Update

I just found out that RedHat is also switching from MySQL to MariaDB for it's default database management system. So it is necessary for my current project to switch it to MariaDB.

解决方案

I was able to use MariaDB 10 with Entity Framework although it required a bit of work mainly because the MySQL tools are a bit buggy.

To work with MySQL/MariaDB in Visual Studio 2010/2012,you need to install MySQL for Visual Studio using MySQL Installer. I used the Web version as I only wanted to download the connectors and the extensions. Once you do this, you can add connections to MariaDB and create EF models.

This is not enough to run your code though. First you need to add the MySQL Connector using NuGet.

Unfortuanetly, MySQL for Visual Studio adds a reference to an older provider version (mentioned here) and can't load the newer version. To fix this, I added the following section in my app.config:

<system.data>
   <DbProviderFactories>
     <remove invariant="MySql.Data.MySqlClient"/>
     <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" 
           description=".Net Framework Data Provider for MySQL" 
           type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
   </DbProviderFactories>
</system.data>

This replaces the old reference with a new one. Note that I used

<remove invariant="MySql.Data.MySqlClient"/>

not

<remove name="MySql Data Provider"/>

in the remove element.

Currently, MySQL for Visual Studio isn't supported in Visual Studio 2013

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆