Entityframeowrk6连接Mysql,mariadb

参考:https://stackoverflow.com/questions/50216643/error-attempt-by-method-x-set-dbconnectionsystem-data-common-dbconnection-to

一些工具下载参考:https://stackoverflow.com/questions/15142841/no-entity-framework-provider-found-for-mysql-data-mysqlclient-ado-net-provider/19898907#19898907

 

网上有很多博文了,就不赘述了,只不过有一点点区别,导致我找了半天

重点就是 MySql.Data.Entity 迁移到了 MySql.Data.EntityFramework

 

引用后,自动在entityFramework.providers节点下增加

<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />

 

system.data.DbProviderFactories 节点下增加 

<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory,MySql.Data" />

 

连接字符串:

<add name="xxxContext" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;port=3306;database=xxx;uid=root;password=123" />

 

DbContext加[DbConfigurationType(typeof(MySqlEFConfiguration))]

posted @ 2020-03-04 18:01  咖喱gg  阅读(385)  评论(0编辑  收藏  举报