笔记

记录一些经常需要复制粘贴的代码

数据库连接字符串(EF Core)

MySql >Server= ;port= ;Database= ;User Id = ;Password= ;sslmode=none

SqlServer >Server= , ;Database= ;User Id = ;Password= ;

划重点MySql使用port声明端口,SqlServer使用,

EF Core

DB First

MySql
不贴了,对2.0支持不好,可以利用SqlServer中转

SqlServer >Scaffold-DbContext "Server= ;Database= ;User Id = ;Password= " Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

SqlServer在执行操作后,需要将XXXContext中的OnConfiguring()替换为 >public XXXContext(DbContextOptions options) : base(options) { }

其中XXX为数据库名称