dotnetcore / osharp

OSharp是一个基于.Net6.0的快速开发框架,框架对 AspNetCore 的配置、依赖注入、日志、缓存、实体框架、Mvc(WebApi)、身份认证、功能权限、数据权限等模块进行更高一级的自动化封装,并规范了一套业务实现的代码结构与操作流程,使 .Net 框架更易于应用到实际项目开发中。
Apache License 2.0
2.76k stars 748 forks source link

新建项目后,按实际环境修改配置OSharp:DbContexts:[MySql]后,执行Update-Database报错 #272

Open ZengOwen opened 2 years ago

ZengOwen commented 2 years ago

PM> Update-Database Build started... Build succeeded. OSharp.Exceptions.OsharpException: 无法解析类型为“MySql”的 OSharp.Entity.IDbContextOptionsBuilderDriveHandler 实例

是我哪里没做对吗

gmf520 commented 2 years ago

应该是没引用 OSharpNS.EntityFrameworkCore.MySql

ZengOwen commented 2 years ago

把Startup.cs 的 ConfigureServices 加上AddPack《MySqlDefaultDbContextMigrationPack》() 可以了

但是执行建立数据库时,依然报错 PM> Update-Database Build started... Build succeeded. System.ArgumentException: An item with the same key has already been added. Key: OSharp.Entity.DefaultDbContext at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)

另外,如果自定义了个Controller, 其中实现了action及对应的url, 那么权限控制表里,会出现这个新的url吗