Что может вызвать System.Data.Entity.Core.MappingException (указанная схема недопустима.) В EF6 Code First? - PullRequest
0 голосов
/ 13 марта 2019

Я использую 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: для отображения условия необходимо указать либо значение, либо атрибут IsNullAttribute.

Ошибка продолжала возникать только на одном из 3 экземпляра приложения , работающие в Azure (служба приложений).Схема базы данных или исходный код не были затронуты.

Перезапуск приложения устранил проблему.

Кто-нибудь, знакомый с архитектурой хостинга 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)
...