在ABP模板工程中使用MySql


1 下載一個新的ABP模板項目

http://www.aspnetboilerplate.com/  

2 在Windows上安裝MySql, 創建一個新的數據庫 sampledb

https://dev.mysql.com/doc/refman/8.0/en/mysql-installer-gui.html - MySql的安裝文檔
https://downloads.mysql.com/archives/installer/ - mysql-installer-gui的下載地址

3 打開模板項目,在EntityFramework和Web項目中安裝 MySql.Data.Entity 

Install-Package MySql.Data.Entity -Version 6.8.3 / Install-Package MySql.Data.Entity   - 安裝MySql.Data.Entity組件的命令

注意: 這里不要安裝最新版本的MySql.Data.Entity, 因為模板項目使用的.net framework版本是4.5.2, 對應的MySql.Data.Entity的版本要使用6.8.3 , 如果使用最新的版本,后面會報錯

4 修改Web.config文件

<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices,          MySql.Data.Entity.EF6" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices,          EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  
<connectionStrings>
<add name="Default" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;port=3306;database=sampledb;uid=root;password=*** " />
</connectionStrings>

關於Ef6 to MySql 可參考文檔 http://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html

5 在Package Manager Console中執行命令 Update-Database –Verbos

6 現在就可以運行ABP的模板項目了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM