我正在使用EntityFramework 6 Code First,并像这样调用IDbSet<>.Any()
方法:
using (var db = _contextFactory.Create())
{
return db.Products
.Any(e => e.CompanyId == companyId && e.Sku == sku);
}
今天早上,Any()
方法开始抛出System.Data.Entity.Core.MappingExceptions并显示以下消息:
指定的架构无效。错误:(94,8):错误2016:必须为条件映射指定Value或IsNullAttribute。
该错误仅在Azure(App Service)中运行的 3个应用程序实例中仅发生一个。尚未触及数据库架构或源代码。
应用程序重新启动解决了该问题。
熟悉Azure托管体系结构的任何人是否知道可能导致此错误的原因?预先感谢!
这是完整的堆栈跟踪:
System.Data.Entity.Core.MappingException:
at System.Data.Entity.Core.Mapping.StorageMappingItemCollection.Init (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Data.Entity.Core.Mapping.StorageMappingItemCollection..ctor (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Data.Entity.ModelConfiguration.Edm.DbDatabaseMappingExtensions.ToStorageMappingItemCollection (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Data.Entity.ModelConfiguration.Edm.DbDatabaseMappingExtensions.ToMetadataWorkspace (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Data.Entity.Internal.CodeFirstCachedMetadataWorkspace.Create (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Data.Entity.Infrastructure.DbModel.Compile (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Data.Entity.Internal.RetryLazy`2.GetValue (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Data.Entity.Internal.InternalContext.Initialize (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Linq.Queryable.Any (System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at Bridge.Pcs.Persistence.ProductRepository.ProductExists (Bridge.Pcs.Persistence, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullBridge.Pcs.Persistence, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Users\Milosh.Mrdovich\Source\Repos\IB\Apcs\Pcs.Persistence\ProductRepository.csBridge.Pcs.Persistence, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 137)
at Bridge.Pcs.Persistence.ProductRepository.ProductExists (Bridge.Pcs.Persistence, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullBridge.Pcs.Persistence, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Users\Milosh.Mrdovich\Source\Repos\IB\Apcs\Pcs.Persistence\ProductRepository.csBridge.Pcs.Persistence, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 28)
at Bridge.Pcs.Core.Infrastructure.LoadOrCreateNewProduct.ProductExistsInRepository (Bridge.Pcs.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullBridge.Pcs.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Users\Milosh.Mrdovich\Source\Repos\IB\Apcs\Pcs.Core\Infrastructure\LoadOrCreateNewProduct.csBridge.Pcs.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 28)
at Bridge.Pcs.Core.Infrastructure.LoadOrCreateNewProduct.Load (Bridge.Pcs.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullBridge.Pcs.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Users\Milosh.Mrdovich\Source\Repos\IB\Apcs\Pcs.Core\Infrastructure\LoadOrCreateNewProduct.csBridge.Pcs.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 21)
at Bridge.Pcs.Core.Services.AuditServiceBase.Audit (Bridge.Pcs.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullBridge.Pcs.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Users\Milosh.Mrdovich\Source\Repos\IB\Apcs\Pcs.Core\Services\AuditServiceBase.csBridge.Pcs.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 42)
at Pcs.Web.Services.TrackingAuditService.Audit (Pcs.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullPcs.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Users\Milosh.Mrdovich\Source\Repos\IB\Apcs\Pcs.Web\Services\TrackingAuditService.csPcs.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 36)
at Pcs.Web.Controllers.Api.LazyAuditController.Post (Pcs.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullPcs.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Users\Milosh.Mrdovich\Source\Repos\IB\Apcs\Pcs.Web\Controllers\Api\LazyAuditController.csPcs.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 25)
at lambda_method (Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor+ActionExecutor+<>c__DisplayClass6_1.<GetExecutor>b__3 (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor+ActionExecutor.Execute (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Controllers.ApiControllerActionInvoker+<InvokeActionAsyncCore>d__1.MoveNext (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Filters.ActionFilterAttribute+<CallOnActionExecutedAsync>d__6.MoveNext (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Http.Filters.ActionFilterAttribute+<CallOnActionExecutedAsync>d__6.MoveNext (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Filters.ActionFilterAttribute+<ExecuteActionFilterAsyncCore>d__5.MoveNext (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Filters.ActionFilterAttribute+<CallOnActionExecutedAsync>d__6.MoveNext (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Http.Filters.ActionFilterAttribute+<CallOnActionExecutedAsync>d__6.MoveNext (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Filters.ActionFilterAttribute+<ExecuteActionFilterAsyncCore>d__5.MoveNext (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Filters.ActionFilterAttribute+<CallOnActionExecutedAsync>d__6.MoveNext (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Http.Filters.ActionFilterAttribute+<CallOnActionExecutedAsync>d__6.MoveNext (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Filters.ActionFilterAttribute+<ExecuteActionFilterAsyncCore>d__5.MoveNext (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Controllers.ActionFilterResult+<ExecuteAsync>d__5.MoveNext (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Dispatcher.HttpControllerDispatcher+<SendAsync>d__15.MoveNext (System.Web.Http, Version=5.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)