How to use MySQL database in ABP framework and related issues

Source: Internet
Author: User
Tags generator connectionstrings

Recently found a framework for DDD

Looks good, it's said to be very bad.

It's going to be nice to have a little something to try out recently.

Struggling to afford to buy high-distribution server, had to install MySQL database

Here's how to use MySQL database in this framework

After you open the project, select * in Package Manager control platform. Entityframwork and *. Web Project (* The prefix for your project name)

Install-package MySql.Data.Entity//install-package MySql.Data.Entity   -command to install MySql.Data.Entity components

Enter the above statement to install MySQL related components

Then change the connection string

<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"/>//can be seen here as well as automatically referencing MySQL related items for us <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=root"/></connectionstrings>

Then update the database in package management control platform

Update-database–verbose

At this point, we can use the project to connect to the MySQL database.

In practice, there are often unexpected problems

Here's a few small questions I've met myself.

1, update the database prompt "Specified key was too long; Max key length is 767 bytes"

This problem is generally due to (I think, welcome Dalao Guidance) Database generator configuration is not correct, the relevant configuration of MSSQL in MySQL is not all applicable

The type of the generator needs to be specified on the DbContext class

[Dbconfigurationtype (typeof(MySql.Data.Entity.MySqlEFConfiguration))]  Public class mycontext:dbcontext{}

Here's mycontext for your EF-related classes

2, forget, remember to write it again

How to use MySQL database in ABP framework and related issues

Related Article

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.