OK, je suis en train d'utiliser Entity Framework, mais je l'ai fait fonctionner, mais j'ai maintenant ajouté plusieurs entités au modèle, et maintenant je suis Obtenir l'erreur ci-dessus Pour le débogage, j'ai créé un formulaire de test avec un contrôle de grille à remplir à partir de ma collection d'entités Projects.J'utilise des GUID pour mes clés primaires.J'ai seulement un bit de code:Entity Framework Exception: l'index était en dehors des limites du tableau. "
Public Class TestForm
Private Sub TestForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ProjectBindingSource.DataSource = My.Application.Context.Projects
End Sub
End Class
Voici le détail d'exception:
Exception interne: { "index était en dehors des limites du tableau."} Source: « System.Data.Entit y "
System.Data.EntityCommandCompilationException était unhandled message =" Une erreur est survenue lors de la préparation de la définition de la commande. Voir l'exception interne pour plus de détails « Source = "System.Data.Entity" StackTrace:. à System.Data.EntityClient.EntityCommandDefinition..ctor (DbProviderFactory storeProviderFactory, DbCommandTree commandTree) à System.Data.EntityClient.EntityProviderServices. CreateCommandDefinition (DbProviderFactory storeProviderFactory, DbCommandTree commandTree) à System.Data.EntityClient.EntityProviderServices.CreateDbCommandDefinition (DbProviderManifest providerManifest, DbCommandTree commandTree) à System.Data.Common.DbProviderServices.CreateCommandDefinition (DbCommandTree commandTree) à System.Data.Objects.Internal .ObjectQueryExecutionPlan.Prepare (contexte ObjectContext, arborescence DbQueryCommandTree, Type elementType, mergeOption mergeOption, span span) à System.Data.Objects.EntitySqlQueryState.GetExecutionPlan (nullables
1 forMergeOption) at System.Data.Objects.ObjectQuery
1.GetResults (Nullable1 forMergeOption) at System.Data.Objects.ObjectQuery
1.GetIListSourceListInternal() à System.Data.Objects.ObjectQuery.System.ComponentModel.IListSource.GetList() à System.Windows. Forms.ListBindingHelper.GetList (Liste d'objets) à System.Windows.Forms.ListBindingHelper.GetList (Object dataSource, String dataMember) à System.Windows.Forms.BindingSource.ResetList() à System.Windows.Forms.BindingSource. set_DataSource (Valeur d'objet) at TestApp.TestForm.TestForm_Load (Expéditeur d'objet, EventArgs e) dans C: \ Users \ JoshPeltier.TFEARTH \ Documents \ Visual Studio 2008 \ Projets \ TestApp \ TestApp \ Forms \ TestForm.vb: ligne 3 at System.EventHandler.Invoke (Expéditeur d'objet, EventA rgs e) à System.Windows.Forms.Form.OnLoad (EventArgs e) à System.Windows.Forms.Form.OnCreateControl() à System.Windows.Forms.Control.CreateControl (Boolean fIgnoreVisible) au système. Windows.Forms.Control.CreateControl() à System.Windows.Forms.Control.WmShowWindow (message & m) à System.Windows.Forms.Control.WndProc (message & m) à System.Windows.Forms.ScrollableControl .WndProc (message & m) à System.Windows.Forms.ContainerControl.WndProc (message & m) à System.Windows.Forms.Form.WmShowWindow (message & m) à System.Windows.Forms.Form.WndProc (message & m) à System.Windows.Forms.Control.ControlNativeWindow.OnMessage (message & m) à System.Windows.Forms.Control.ControlNativeWindow.WndProc (message & m) à System.Windows.Forms.NativeWindow.DebuggableCallback (IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) à System.Windows.Forms.SafeNativeMethods.ShowWindow (HWND HandleRef, Int32 nCmdShow) à System.Windows.Forms.Control.SetVisibleCore (valeur booléenne) à System.Windows.Forms.Form.SetVisibleCore (valeur booléenne) à System.Windows.Forms.Control.set_Visible (valeur booléenne) à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner (en raison Int32, contexte ApplicationContext) à System.Windows.Forms.Application.ThreadContext.RunMessageLoop (en raison Int32, contexte ApplicationContext) à System.Windows.Forms .Application.Run (contexte ApplicationContext) à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Micros oft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run (String [] commandLine) à TestApp.My.MyApplication.Main (String [] Args) dans 17d14f5c-a337-4978-8281-53493378c1071.vb: ligne 81 à System.AppDomain ._nExecuteAssembly (assemblage de montage, String [] args) à System.AppDomain.ExecuteAssembly (String assemblyFile, Evidence assemblySecurity, String [] args) à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() à System.Threading.ThreadHelper .ThreadStart_Context (état de l'objet) à System.Threading.ExecutionContext.Run (ExecutionContext ExecutionContext, ContextCallback rappel, l'état de l'objet) à System.Threading.ThreadHelper.ThreadStart() InnerException: System.IndexOutOfRangeException Message = "L'index était en dehors des limites du tableau." Source = "System.Data.Entity" StackTrace: à System.Data.Mapping.ViewGeneration.Structures.CellQuery.CreateFieldAlignedCellQueries (CellQuery otherQuery, MemberPathMapBase projectedSlotMap, CellQuery & newMainQuery, CellQuery & newOtherQuery) à System.Data.Mapping .ViewGeneration.CellNormalizer.AlignFields (IEnumerable1 cells, MemberPathMapBase projectedSlotMap, ViewTarget viewTarget) at System.Data.Mapping.ViewGeneration.CellNormalizer.CreateLeftCellWrappers(IEnumerable
1 extentCells, viewTarget viewTarget) à System.Data.Mapping.ViewGeneration.CellNormalizer..ctor (EntitySetBase mesure, IEnumerable1 extentCells, SchemaContext schemaContext, CqlIdentifiers identifiers, ConfigViewGenerator config, MemberDomainMap queryDomainMap, MemberDomainMap updateDomainMap, StorageEntityContainerMapping entityContainerMapping, MetadataWorkspace workspace) at System.Data.Mapping.ViewGeneration.ViewGenerator.GetCellNormalizer(EntitySetBase extent, SchemaContext schemaContext, CqlIdentifiers identifiers) at System.Data.Mapping.ViewGeneration.ViewGenerator.GenerateViewsForExtent(SchemaContext schemaContext, EntitySetBase extent, CqlIdentifiers identifiers, KeyToListMap
2 fois) à System.Data.Mapping.ViewGeneration.ViewGenerator. GenerateViewsForSchemaContext (SchemaContext schemaContext, identificateurs CqlIdentifiers, KeyToListMap2 views) at System.Data.Mapping.ViewGeneration.ViewGenerator.GenerateAllViews(KeyToListMap
2 vues, CqlIdentifier s identificateurs) à System.Data.Mapping.ViewGeneration.ViewGenerator.GenerateViewsForSchemaCells (Liste1 cells, MetadataWorkspace workSpace, ConfigViewGenerator config, CqlIdentifiers identifiers, StorageEntityContainerMapping containerMapping) at System.Data.Mapping.ViewGeneration.ViewGenerator.GenerateViewsForSchema(StorageEntityContainerMapping containerMapping, MetadataWorkspace workSpace, ConfigViewGenerator config) at System.Data.Mapping.StorageMappingItemCollection.ViewDictionary.SerializedGenerateViews(EntityContainer container, Dictionary
2 resultDictionary) à System.Data.Mapping.StorageMappingItemCollection.ViewDictionary.SerializedGetGeneratedViews (Conteneur à EntityContainer) à System.Data.Common.Utils.Memoizer2.<>c__DisplayClass2.<Evaluate>b__0() at System.Data.Common.Utils.Memoizer
2.Result.GetValue() à System.Data.Common.Utils.Memoizer2.Evaluate(TArg arg) at System.Data.Mapping.StorageMappingItemCollection.ViewDictionary.GetGeneratedView(EntitySetBase extent, MetadataWorkspace workspace, StorageMappingItemCollection storageMappingItemCollection) at System.Data.Metadata.Edm.MetadataWorkspace.GetGeneratedView(EntitySetBase extent) at System.Data.Query.PlanCompiler.PreProcessor.ExpandView(Node node, ScanTableOp scanTableOp, IsOfOp& typeFilter) at System.Data.Query.PlanCompiler.PreProcessor.ProcessScanTable(Node scanTableNode, ScanTableOp scanTableOp, IsOfOp& typeFilter) at System.Data.Query.PlanCompiler.PreProcessor.Visit(ScanTableOp op, Node n) at System.Data.Query.InternalTrees.ScanTableOp.Accept[TResultType](BasicOpVisitorOfT
1 v, noeud N) à System.Data.Query.InternalTrees.BasicOpVisitorOfT1.VisitNode(Node n) at System.Data.Query.PlanCompiler.PreProcessor.VisitChildren(Node n) at System.Data.Query.PlanCompiler.PreProcessor.VisitRelOpDefault(RelOp op, Node n) at System.Data.Query.PlanCompiler.PreProcessor.Visit(ProjectOp op, Node n) at System.Data.Query.InternalTrees.ProjectOp.Accept[TResultType](BasicOpVisitorOfT
1 v, noeud N) à System.Data. Query.InternalTrees.BasicOpVisitorOfT1.VisitNode(Node n) at System.Data.Query.PlanCompiler.PreProcessor.VisitChildren(Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitDefault(Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitPhysicalOpDefault(PhysicalOp op, Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfT
1.Visit (Opération PhysicalProjectOp, Noeud n) à System.Data.Query.InternalTrees.PhysicalProjectOp.Accept [TResultType] (BasicOpVisitorOfT1 v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfT
1.VisitNode (Node n) à System.Data.Query.PlanCompiler.PreProcessor.Process() à System.Data.Query.PlanCompiler.PreProcessor.Process (PlanCompiler planCompilerState, StructuredTypeInfo & typeinfo) à System.Data. Query.PlanCompiler.PlanCompiler.Compile (Liste entitySets) à System.Data.Query.PlanCompiler.PlanCompiler.Compile (DbCommandTree ctree, Liste entitySets) à System.Data.EntityClient.EntityCommandDefinition ..cteur (DbProviderFactory storeProviderFactory, DbCommandTree commandTree) InnerException:
Toutes les idées?
Je reçois exactement la même erreur. J'ai utilisé ce modèle pendant un certain temps sans erreur, mais après avoir modifié quelques bases de données et mis à jour le modèle, cette erreur est apparue. La solution est construite sans erreur mais cette erreur est répertoriée dans la liste d'erreurs. Lorsque je lance l'application, j'obtiens l'erreur dès que j'essaie d'accéder au modèle. –