ASP. NET core2.0 connect MySQL and MSSQL

Source: Internet
Author: User
Tags mssql

Transferred from: Https://www.jianshu.com/p/15a557ac43d9

1. Connect to MySQL

First step, create a new ASP. NET Core Project

New Project

This routine is a simple demonstration of the connection between the two databases, creating a new default Webapi project and adding the MySQL. NET core package to the current preview version. Note: Core 1.0 1.1 can be used with MySQL official, 2.0 will be the error suggested with Pomelo

MySQL 1.1

Pomelo 2.0

Then create a new code First database entity

Code First

Then write the configuration in the Startup.cs file

Startup.cs

Write the connection string in the Appsetting.json file, note that the string name must be the same as in the previous step, and Sslmode must be.

Appsetting.json

Next, write a simple method in the controller that queries the first data and then returns the JSON.

Apicontroller

The operation results are as follows

This is the result of running 2. The connection of MSSQL is similar to that of MySQL and needs to be installed

Support for. NET core 2.0 to modify the connection string.



ASP. NET core2.0 connect MySQL and MSSQL

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.