.NET core 连接db2数据库问题,请大牛支持
目前环境
1. 开发环境 :vs2019 ,.net stardard2.0 ,前端 vue 后端 .net core +webapi, win10企业版 数据库本地
2. ORM 使用 ef ,codefirst
3. db2 数据库组件:ibm.data.db2.core 版本(1.3.0.100)
ibm.EntityFrameworkCore(1.3.0.100)
4. db2 数据库: 安装的产品:DB2 Express-C - DB2COPY1, 版本:DB2/NT64 10.1.0
5. db2数据库配置文件:appsettings.json
6. 配置字符串为(可能存在问题请指正):
"ConnectionStrings": [
{
"Key": "default",
"Value": "Provider=IBMDADB2.DB2COPY1;Data Source=idms;Persist Security Info=True;User ID=idms;Password=idms"
}
],
"DBType": "DB2", //使用的数据库
7. 配置代码 DataContext.cs(部分,大牛1看就明白):
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
case DBTypeEnum.DB2:
optionsBuilder.UseDb2(CSName,p=>p.SetServerInfo(IBMDBServerType.LUW, IBMDBServerVersion.None));
break;
}
运行时,报一下错误,由于db2 相关资料比较少,很难找到原因,请大牛帮忙解决问题,请帮忙分析一下,如果帮助解决问题,在加一盒烟钱,哈哈。
info: Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler[7]
Cookies was not authenticated. Failure message: Ticket expired
info: Microsoft.AspNetCore.ResponseCaching.ResponseCachingMiddleware[24]
No cached response available for this request.
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
System.AggregateException: One or more errors occurred. (Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Storage.IDatabaseCreator'. This is often because no database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.) ---> System.InvalidOperationException: Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Storage.IDatabaseCreator'. This is often because no database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.
at Microsoft.EntityFrameworkCore.Internal.InternalAccessorExtensions.GetService[TService](IInfrastructure`1 accessor)
at Microsoft.EntityFrameworkCore.Infrastructure.AccessorExtensions.GetService[TService](IInfrastructure`1 accessor)
at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.get_DatabaseCreator()
at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.EnsureCreatedAsync(CancellationToken cancellationToken)
at WalkingTec.Mvvm.Core.FrameworkContext.DataInit(Object allModules, Boolean IsSpa) 。