Entityframeowrk6连接Mysql,mariadb
网上有很多博文了,就不赘述了,只不过有一点点区别,导致我找了半天
重点就是 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))]