打开VS,工具》NuGet包管理器》管理解决方案的NuGet程序包,搜索MySql.Data并安装
测试连接MySQL的代码:
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using MySql.Data.MySqlClient;
namespace ZZTCore.Controllers
{
public class LoginController : Controller
{
public IActionResult Index()
{
DataTable dt = new DataTable();
DataSet ds = new DataSet();
try
{
using (MySqlConnection con = new MySqlConnection("Data Source=localhost;User ID=root;Password=zt102545;Database=employees;Allow User Var