ABP Framework connects to MySQL database

Source: Internet
Author: User



Started to use the ABP framework to build the company's new projects, although everything is not set, but the soldiers did not move, fodder first, I will try the whole process, to better to win the opportunity.



This technology selection: ABP (ASP. NET core MVC) +mysql (8.0) +docker



ABP Website Address: https://aspnetboilerplate.com/






1. Installing MySQL-related packages in NuGet, the MySQL package provided by Oracle company is still problematic, so it is now used by third-party MySQL packages.



Pomelo. Entityframeworkcore. mysql



Pomelo.entityframeworkcore.mysql. Design









2, find xxdbcontextconfigurer in the Entityframeworkcore layer, modify the database configuration in the DbContext, SQL Server by default, and modify it to MySQL.






3. Modify the connection string, locate the Appsetting.json file under Web.host or WEB.MVC, and modify the connection string.


" Default " " server=xxx.xxx.xxx.xxx; database=surrounddb;charset=utf8;uid=root;pwd=123456; "


I installed a MySQL database directly under Docker in the server, so it will be used directly in the development environment.






4, start to update the database, you can delete the Migrations folder under the Entityframeworkcore layer does not affect, which is the version of the history of the database migration brought, not important to us.



Under Package Manager console, select Entityframeworkcore and start entering commands



Pm>add-migration name (Take one of the updated names)



Hint message: To-undo this action, use Remove-migration.



Pm>update-database



No errors will be prompted as follows:



Hint message: Applying migration ' 20180809141445_initall '.



Done.









5, start the website, successfully opened and connected, if the table structure changes, update the database, just run the previous two lines of command.






Attention:



1, my MySQL database version is higher than 5.7, the mysql5.7 will be reported some errors, such as: Specified key was too long; Max key length is 767 bytes and the like.



Because this version of MySQL uses different encoding methods, choose to upgrade version, by modifying the code of MySQL solution (79521812)



2. If Ssl=none is added to the connection string, the error will be removed.

2018-08-09, I hope I can come back and see my steps after the technology is successful

 





ABP Framework connects to MySQL database


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.