Models-->实体类
IAltestitemController.cs
AlltestitemService.cs
Controllers-> AlltestitemController.cs
Copy
Install-Package MySql.Data.EntityFrameworkCore -Pre
Install-Package Pomelo.EntityFrameworkCore.MySql
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design
Copy
Scaffold-DbContext "server=localhost;userid=root;pwd=1;port=3306;database=syerp;sslmode=none;" Pomelo.EntityFrameworkCore.MySql -OutputDir Models -Force
添加IAlltestitemService.cs接口
Copy
using AfterCore.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace After.IService
{
public interface IAlltestitemService
{
After.Service接口实现
AlltestitemService.cs
Copy
using After.IService;
using AfterCore.Models;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace After.Service
{
public class AlltestitemService : IAlltestitemService
{
private readonly testContext _testDbContext;
Copy
"ConnectionStrings": {
"DefaultConnection": "Server=;database=test;uid=root;pwd=m;"
},
Copy
Copy
Swashbuckle.AspNetCore
Copy
Copy
Controllers->AlltestitemController.cs
Copy
using After.IService;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
Original: https://www.cnblogs.com/zxtceq/p/14207638.html
Author: 从未被超越
Title: netcore3.1API+efcore快速搭建