ABP使用.Net Core

xiaoxiao2021-02-28  42

参考:https://www.cnblogs.com/donaldtdz/p/8149598.html

1.下载模板:https://aspnetboilerplate.com/Templates

2.移除默认SQL Server相关包

在EntityFrameworkCore项目下移除包Microsoft.EntityFrameworkCore.SqlServerMicrosoft.EntityFrameworkCore.Design

3.添加MySql程序包

 添加程序包Pomelo.EntityFrameworkCore.MySqlPomelo.EntityFrameworkCore.MySql.Design

4.修改源代码

修改DbContextConfigurer

public static class AbpBasicDbContextConfigurer { public static void Configure(DbContextOptionsBuilder<AbpBasicDbContext> builder, string connectionString) { //builder.UseSqlServer(connectionString); builder.UseMySql(connectionString); } public static void Configure(DbContextOptionsBuilder<AbpBasicDbContext> builder, DbConnection connection) { //builder.UseSqlServer(connection); builder.UseMySql(connection); } } 5.修改数据库链接字符串

在web项目配置文件appsettings.json

"ConnectionStrings": { "Default": "Server=localhost;Database=testabpcore;uid=root;pwd=root;" }6.修改 Web.Host项目中Program.cs

public class Program { public static void Main(string[] args) { BuildWebHost2(args).Run(); } private static IWebHost BuildWebHost2(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .Build(); }

7.修改Web.Host为启动项目,然后迁移数据库

删除 .EntityFramework 项目中的Migrations文件夹下所有文件,然后控制台执行:

Add-Migration "AbpZero_Initial"

Update-Database8.迁移完成,然后启动。

转载请注明原文地址: https://www.6miu.com/read-2300397.html

最新回复(0)