• 【变态问题】在发现“XXXX”类型前实体框架已使用默认 DbConfiguration 实例。


    今天在调试MVC反射调用EF写的dll

    一直报错如下:

    在发现“VipHallDbConfiguration”类型前实体框架已使用默认 DbConfiguration 实例。“VipHallDbConfiguration”的实例必须在使用任何实体框架功能前在应用程序启动时设置或必须在应用程序的 config 文件中注册。

    具体描述:

    System.Reflection.TargetInvocationException: 调用的目标发生了异常。 
    ---> System.TypeInitializationException: “Server5.V2.Data.VipHallContext”的类型初始值设定项引发异常。 
    ---> System.InvalidOperationException: 在发现“VipHallDbConfiguration”类型前实体框架已使用默认 DbConfiguration 实例。“VipHallDbConfiguration”的实例必须在使用任何实体框架功能前在应用程序启动时设置或必须在应用程序的 config 文件中注册。
    有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=260883。 
    在 System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.EnsureLoadedForAssembly(Assembly assemblyHint, Type contextTypeHint) 
    在 System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.EnsureLoadedForContext(Type contextType) 在 System.Data.Entity.Database.SetInitializer[TContext](IDatabaseInitializer`1 strategy) 
    在 Server5.V2.Data.VipHallContext..cctor() 位置 D:JSJJSJ_S5ServerServer5.V2DataVipHallContext.cs:行号 36 --- 内部异常堆栈跟踪的结尾 --- 在 Server5.V2.Data.VipHallContext..ctor() 
    在 Server5.V2.BLL.BllBase..ctor(LogModule LogModule) 位置 D:JSJJSJ_S5ServerServer5.V2BLLBllBase.cs:行号 44 
    在 Server5.V2.BLL.ThirdPartyBll..ctor() 位置 D:JSJJSJ_S5ServerServer5.V2BLLThirdPartyBll.cs:行号 25 
    在 Server5.V2.API.CooperationApi._RefoundCoupon(RefoundCouponRequest request) 位置 D:JSJJSJ_S5ServerServer5.V2APICooperationApi.cs:行号 88 --- 内部异常堆栈跟踪的结尾 --- 
    在 System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) 在 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) 
    在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 在 System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) 
    在 Server5.Api.V3.Controllers.BaseController.DoReq(String ac) 位置 D:JSJJSJ_S5ServerServer5.Api.V3ControllersBaseController.cs:行号 41

    报错截图:

    报错里给出了一个英文的文档地址:https://msdn.microsoft.com/zh-cn/data/jj680699

    但是看了半天还是不知道问题出在哪里。。。

    哎!!!

    今天又遇到了,是MVC的版本里已经自带了一个EF的初始化,所以冲突,选择了空模版的MVC新建一个项目就好了,所有的东西自己新建,不用系统的初始内容。

  • 相关阅读:
    【转】每天一个linux命令(52):ifconfig命令
    【转】每天一个linux命令(51):lsof命令
    linux挂载SD卡
    【转】每天一个linux命令(50):crontab命令
    【转】每天一个linux命令(49):at命令
    【转】每天一个linux命令(48):watch命令
    【转】每天一个linux命令(47):iostat命令
    【转】每天一个linux命令(46):vmstat命令
    【转】每天一个linux命令(45):free 命令
    【转】每天一个linux命令(44):top命令
  • 原文地址:https://www.cnblogs.com/jhli/p/7168698.html
Copyright © 2020-2023  润新知