Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 索引超出了数组实体框架的范围_C#_Entity Framework_Asp.net Mvc 4 - Fatal编程技术网

C# 索引超出了数组实体框架的范围

C# 索引超出了数组实体框架的范围,c#,entity-framework,asp.net-mvc-4,C#,Entity Framework,Asp.net Mvc 4,我在Entity Framework中遇到了这个问题,它只发生在一个应用程序中,同样的代码也适用于我团队中的其他应用程序。同时,我对本地的其他应用程序没有任何问题。很奇怪 我的代码如下所示,到处都是错误(无论在哪里访问表)。即使验证了我的edmx文件,看起来也不错。但同样的edmx也适用于其他人: tblTest testEntity = _repositoryFactory.Create<tblTest>().Query() .SingleOrDef

我在Entity Framework中遇到了这个问题,它只发生在一个应用程序中,同样的代码也适用于我团队中的其他应用程序。同时,我对本地的其他应用程序没有任何问题。很奇怪

我的代码如下所示,到处都是错误(无论在哪里访问表)。即使验证了我的edmx文件,看起来也不错。但同样的edmx也适用于其他人:

tblTest testEntity = _repositoryFactory.Create<tblTest>().Query()
                .SingleOrDefault(t => t.pkTest_ID == 100);
堆栈跟踪:

at System.Xml.Schema.RangeContentValidator.ValidateElement(XmlQualifiedName name, ValidationState context, Int32& errorCode)
   at System.Xml.Schema.XmlSchemaValidator.ValidateElementContext(XmlQualifiedName elementName, Boolean& invalidElementInContext)
   at System.Xml.Schema.XmlSchemaValidator.ValidateElement(String localName, String namespaceUri, XmlSchemaInfo schemaInfo, String xsiType, String xsiNil, String xsiSchemaLocation, String xsiNoNamespaceSchemaLocation)
   at System.Xml.XsdValidatingReader.ProcessElementEvent()
   at System.Xml.XsdValidatingReader.Read()
   at System.Data.Entity.Core.SchemaObjectModel.SchemaElement.Parse(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.EntityContainer.HandleAssociationSetElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.EntityContainer.HandleElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.SchemaElement.ParseElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.SchemaElement.Parse(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.Schema.HandleEntityContainerTypeElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.Schema.HandleElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.SchemaElement.ParseElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.SchemaElement.Parse(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.Schema.HandleTopLevelSchemaElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.Schema.InternalParse(XmlReader sourceReader, String sourceLocation)
   at System.Data.Entity.Core.SchemaObjectModel.Schema.Parse(XmlReader sourceReader, String sourceLocation)
   at System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, AttributeValueNotification providerNotification, AttributeValueNotification providerManifestTokenNotification, ProviderManifestNeeded providerManifestNeeded, IList`1& schemaCollection)
   at System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, DbProviderManifest providerManifest, IList`1& schemaCollection)
   at System.Data.Entity.Core.Metadata.Edm.EdmItemCollection.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModelOption, DbProviderManifest providerManifest, ItemCollection itemCollection, Boolean throwOnError)
   at System.Data.Entity.Core.Metadata.Edm.EdmItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError)
   at System.Data.Entity.Core.Metadata.Edm.EdmItemCollection..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean skipInitialization)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.LoadEdmItemCollection(MetadataArtifactLoader loader)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.<>c__DisplayClass5.<GetMetadataWorkspace>b__0(String k)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace(String cacheKey, MetadataArtifactLoader artifactLoader)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace(DbConnectionOptions effectiveConnectionOptions)
   at System.Data.Entity.Core.EntityClient.EntityConnection.GetMetadataWorkspace()
   at System.Data.Entity.Core.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection()
   at System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor, ObjectQueryExecutionPlanFactory objectQueryExecutionPlanFactory, Translator translator, ColumnMapFactory columnMapFactory)
   at System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection)
   at System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel()
   at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.Initialize()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
   at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
   at Crius.Sites.BackOffice.Controllers.ErrorController.Index(String id) in c:\Crius\DotNet\Crius.Sites\Crius.Sites.BackOffice\branches\v15\Crius.Sites.BackOffice\Controllers\ErrorController.cs:line 37
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
位于System.Xml.Schema.RangeContentValidator.ValidateElement(XmlQualifiedName名称、ValidationState上下文、Int32&errorCode)
位于System.Xml.Schema.XmlSchemaValidator.ValidateElementContext(XmlQualifiedName elementName,Boolean&invalidelElementContext)
位于System.Xml.Schema.XmlSchemaValidator.ValidateElement(字符串localName、字符串namespaceUri、XmlSchemaInfo schemaInfo、字符串xsiType、字符串xsiNil、字符串xsiSchemaLocation、字符串xsiNoNamespaceSchemaLocation)
位于System.Xml.XsdValidatingReader.ProcessElementEvent()处
在System.Xml.XsdValidatingReader.Read()中
位于System.Data.Entity.Core.SchemaObjectModel.SchemaElement.Parse(XmlReader)
位于System.Data.Entity.Core.SchemaObjectModel.EntityContainer.HandleAssociationSetElement(XmlReader)
位于System.Data.Entity.Core.SchemaObjectModel.EntityContainer.HandleElement(XmlReader)
位于System.Data.Entity.Core.SchemaObjectModel.SchemaElement.ParseElement(XmlReader)
位于System.Data.Entity.Core.SchemaObjectModel.SchemaElement.Parse(XmlReader)
位于System.Data.Entity.Core.SchemaObjectModel.Schema.HandleEntityContainerTypeElement(XmlReader)
位于System.Data.Entity.Core.SchemaObjectModel.Schema.HandleElement(XmlReader)
位于System.Data.Entity.Core.SchemaObjectModel.SchemaElement.ParseElement(XmlReader)
位于System.Data.Entity.Core.SchemaObjectModel.SchemaElement.Parse(XmlReader)
位于System.Data.Entity.Core.SchemaObjectModel.Schema.HandletoLevel SchemaElement(XmlReader)
位于System.Data.Entity.Core.SchemaObjectModel.Schema.InternalParse(XmlReader sourceReader,String sourceLocation)
位于System.Data.Entity.Core.SchemaObjectModel.Schema.Parse(XmlReader sourceReader,String sourceLocation)
位于System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders,IEnumerable`1 SourceFilePath,SchemaDataModel,AttributeValueNotification providerNotification,AttributeValueNotification providerManifestTokenNotification,ProviderManifestRequired ProviderManifestRequired,IList`1&schemaCollection)
位于System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders、IEnumerable`1 SourceFilePath、SchemaDataModel、DbProviderManifest providerManifest、IList`1和schemaCollection)
位于System.Data.Entity.Core.Metadata.Edm.EdmItemCollection.LoadItems(IEnumerable`1 xmlReaders,IEnumerable`1 SourceFilePath,SchemaDataModelOption,DbProviderManifest providerManifest,ItemCollection ItemCollection,Boolean throwOnError)
位于System.Data.Entity.Core.Metadata.Edm.EdmItemCollection.Init(IEnumerable`1 xmlReaders、IEnumerable`1文件路径、布尔throwOnError)
位于System.Data.Entity.Core.Metadata.Edm.EdmItemCollection..ctor(IEnumerable`1 xmlReaders,IEnumerable`1文件路径,布尔skipInitialization)
位于System.Data.Entity.Core.Metadata.Edm.MetadataCache.LoadedItemCollection(MetadataArtifactLoader)
位于System.Data.Entity.Core.Metadata.Edm.MetadataCache.c__DisplayClass5.b__0(字符串k)
位于System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey,Func`2 valueFactory)
位于System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace(String cacheKey,MetadataArtifactLoader-artifactLoader)
位于System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace(DbConnectionOptions有效连接选项)
位于System.Data.Entity.Core.EntityClient.EntityConnection.GetMetadataWorkspace()处
位于System.Data.Entity.Core.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection()处
位于System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection连接、Boolean IsConnection构造函数、ObjectQueryExecutionPlanFactory ObjectQueryExecutionPlanFactory、转换器转换器、ColumnMapFactory ColumnMapFactory)
位于System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection连接)
位于System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel()处
位于System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()处
在System.Data.Entity.Internal.LazyInternalContext.InitializeContext()中
位于System.Data.Entity.Internal.InternalContext.Initialize()处
位于System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(类型entityType)
位于System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
位于System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
位于System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
位于System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1源,表达式`1谓词)
在c:\Crius\DotNet\Crius.Sites\Crius.Sites.BackOffice\branchs\v15\Crius.Sites.BackOffice.Controllers.ErrorController.Index(字符串id)中:第37行
在lambda_方法中(闭包、控制器基、对象[])
位于System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller,Object[]参数)
位于System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext ControllerContext,IDictionary`2参数)
位于System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext ControllerContext,ActionDescriptor ActionDescriptor,IDictionary`2参数)
在System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvoke.InvokeSynchronousActionMethod()中
位于System.Web.Mvc.Async.AsyncControllerActionInvoker。
at System.Xml.Schema.RangeContentValidator.ValidateElement(XmlQualifiedName name, ValidationState context, Int32& errorCode)
   at System.Xml.Schema.XmlSchemaValidator.ValidateElementContext(XmlQualifiedName elementName, Boolean& invalidElementInContext)
   at System.Xml.Schema.XmlSchemaValidator.ValidateElement(String localName, String namespaceUri, XmlSchemaInfo schemaInfo, String xsiType, String xsiNil, String xsiSchemaLocation, String xsiNoNamespaceSchemaLocation)
   at System.Xml.XsdValidatingReader.ProcessElementEvent()
   at System.Xml.XsdValidatingReader.Read()
   at System.Data.Entity.Core.SchemaObjectModel.SchemaElement.Parse(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.EntityContainer.HandleAssociationSetElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.EntityContainer.HandleElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.SchemaElement.ParseElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.SchemaElement.Parse(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.Schema.HandleEntityContainerTypeElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.Schema.HandleElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.SchemaElement.ParseElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.SchemaElement.Parse(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.Schema.HandleTopLevelSchemaElement(XmlReader reader)
   at System.Data.Entity.Core.SchemaObjectModel.Schema.InternalParse(XmlReader sourceReader, String sourceLocation)
   at System.Data.Entity.Core.SchemaObjectModel.Schema.Parse(XmlReader sourceReader, String sourceLocation)
   at System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, AttributeValueNotification providerNotification, AttributeValueNotification providerManifestTokenNotification, ProviderManifestNeeded providerManifestNeeded, IList`1& schemaCollection)
   at System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, DbProviderManifest providerManifest, IList`1& schemaCollection)
   at System.Data.Entity.Core.Metadata.Edm.EdmItemCollection.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModelOption, DbProviderManifest providerManifest, ItemCollection itemCollection, Boolean throwOnError)
   at System.Data.Entity.Core.Metadata.Edm.EdmItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError)
   at System.Data.Entity.Core.Metadata.Edm.EdmItemCollection..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean skipInitialization)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.LoadEdmItemCollection(MetadataArtifactLoader loader)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.<>c__DisplayClass5.<GetMetadataWorkspace>b__0(String k)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace(String cacheKey, MetadataArtifactLoader artifactLoader)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace(DbConnectionOptions effectiveConnectionOptions)
   at System.Data.Entity.Core.EntityClient.EntityConnection.GetMetadataWorkspace()
   at System.Data.Entity.Core.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection()
   at System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor, ObjectQueryExecutionPlanFactory objectQueryExecutionPlanFactory, Translator translator, ColumnMapFactory columnMapFactory)
   at System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection)
   at System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel()
   at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.Initialize()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
   at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
   at Crius.Sites.BackOffice.Controllers.ErrorController.Index(String id) in c:\Crius\DotNet\Crius.Sites\Crius.Sites.BackOffice\branches\v15\Crius.Sites.BackOffice\Controllers\ErrorController.cs:line 37
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()