• 讓 MySQL 能夠用 EF6


    http://www.dotblogs.com.tw/yc421206/archive/2014/03/14/144395.aspx

    要讓 MySQL 能夠用 EF6,我花了一點時間,在此記錄一下

    安裝元件

    在設定檔加入Provider


    安裝元件

    從 NuGet 安裝 MySql.Data.Entities

    image

    完成後,就會看到相關元件已經被加入到專案裡

    image

    接下來加入 MySQL 的 Model

    image

    image

    image

    image

    無法使用EF6

    image


    在設定檔加入Provider

    這時需要在 App.config/Web.Config加入以下 Provider,然後按下存檔

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

    完整設定檔如下:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
      </startup>
      <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" />
          <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"></provider>
        </providers>
      </entityFramework>
    </configuration>

    這時候就可以加入MySQL Model

    image


    文章出自:http://www.dotblogs.com.tw/yc421206/archive/2014/03/14/144395.aspx

    若有謬誤,煩請告知,新手發帖請多包涵

  • 相关阅读:
    爱信诺面试总结
    项目进展日志6
    项目进展日志5
    项目进展日志4
    项目进展日志3
    项目进展日志2
    项目阶段总结
    项目进展日志
    事物的ACID特性
    5.27作业
  • 原文地址:https://www.cnblogs.com/Rising/p/3788589.html
Copyright © 2020-2023  润新知