在ABP模板工程中使用MySql

來源:互聯網
上載者:User

標籤:connect   dev   localhost   cto   cli   down   efault   config   console   

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的模板項目了

 

在ABP模板工程中使用MySql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.