Vb.net 实体框架异常:索引超出了数组的边界;
好的,我有实体框架的问题。我已经让它工作了,但是现在已经在模型中添加了多个实体,现在我得到了上面的错误。出于调试目的,我创建了一个带有网格控件的测试表单,以从我的项目实体集合中填充。仅供参考,我正在使用GUID作为主键。我只有一点代码:Vb.net 实体框架异常:索引超出了数组的边界;,vb.net,entity-framework,ado.net,Vb.net,Entity Framework,Ado.net,好的,我有实体框架的问题。我已经让它工作了,但是现在已经在模型中添加了多个实体,现在我得到了上面的错误。出于调试目的,我创建了一个带有网格控件的测试表单,以从我的项目实体集合中填充。仅供参考,我正在使用GUID作为主键。我只有一点代码: Public Class TestForm Private Sub TestForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
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
以下是异常详细信息:
内部异常:{“索引超出了数组的边界。”}
来源:“System.Data.Entity”
System.Data.EntityCommandCompliationException未处理
Message=“准备命令定义时出错。有关详细信息,请参阅内部异常。”
Source=“System.Data.Entity”
堆栈跟踪:
位于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(ObjectContext上下文,DbQueryCommandTree树,类型elementType,MergeOption,合并选项,跨距)
位于System.Data.Objects.EntitySqlQueryState.GetExecutionPlan(可为Nullable1 forMergeOption)
在System.Data.Objects.ObjectQuery中
1.GetResults(Nullable1 forMergeOption)
位于System.Data.Objects.ObjectQuery
1.GetIListSourceListInternal()
位于System.Data.Objects.ObjectQuery.System.ComponentModel.IListSource.GetList()处
位于System.Windows.Forms.ListBindingHelper.GetList(对象列表)
位于System.Windows.Forms.ListBindingHelper.GetList(对象数据源,字符串数据成员)
在System.Windows.Forms.BindingSource.ResetList()中
位于System.Windows.Forms.BindingSource.set_数据源(对象值)
在C:\Users\JoshPeltier.TFEARTH\Documents\visualstudio 2008\Projects\TestApp\TestApp\Forms\TestForm.vb中的TestApp.TestForm\u加载(对象发送方,事件参数e):第3行
在System.EventHandler.Invoke(对象发送方,EventArgs e)
在System.Windows.Forms.Form.OnLoad(EventArgs e)中
在System.Windows.Forms.Form.OnCreateControl()中
位于System.Windows.Forms.Control.CreateControl(布尔值不可修改)
在System.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(消息和消息)
在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(HandleRef hWnd,Int32 nCmdShow)
位于System.Windows.Forms.Control.SetVisibleCore(布尔值)
位于System.Windows.Forms.Form.SetVisibleCore(布尔值)
在System.Windows.Forms.Control.set_可见(布尔值)
位于System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32原因,ApplicationContext上下文)
位于System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32原因,ApplicationContext上下文)
位于System.Windows.Forms.Application.Run(ApplicationContext上下文)
在Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()上
在Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()上
在Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(字符串[]命令行)
在17d14f5c-a337-4978-8281-53493378c1071中的TestApp.My.MyApplication.Main(字符串[]Args)处。vb:第81行
位于System.AppDomain.\u nexecutestAssembly(程序集,字符串[]args)
位于System.AppDomain.ExecuteAssembly(字符串汇编文件、证据汇编安全性、字符串[]args)
在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()上
位于System.Threading.ThreadHelper.ThreadStart\u上下文(对象状态)
在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态)
位于System.Threading.ThreadHelper.ThreadStart()处
InnerException:System.IndexOutOfRangeException
Message=“索引超出了数组的边界。”
Source=“System.Data.Entity”
堆栈跟踪:
位于System.Data.Mapping.ViewGeneration.Structures.CellQuery.CreateFieldAlignedCellQueries(CellQuery-otherQuery、MemberPathMapBase-projectedSlotMap、CellQuery&newMainQuery、CellQuery&newOtherQuery)
位于System.Data.Mapping.ViewGeneration.CellNormalizer.AlignFields(IEnumerable1单元格,MemberPathMapBase projectedSlotMap,ViewTarget ViewTarget)
位于System.Data.Mapping.ViewGeneration.CellNormalizer.CreateLeftCellWrappers(IEnumerable
1 extentCells,ViewTarget-ViewTarget)
位于System.Data.Mapping.ViewGeneration.CellNormalizer..ctor(EntitySetBase区段、IEnumerable1扩展单元格、SchemaContext SchemaContext、CqlIdentifiers标识符、ConfigViewGenerator配置、MemberDomainMap queryDomainMap、MemberDomainMap updateDomainMap、StorageEntityContainerMapping entityContainerMapping、MetadataWorkspace工作区)
在System.Data.Mapping.ViewG
<AssociationSetMapping Name="Table1Table2" TypeName="MyModel.Table1Table2" StoreEntitySet="Table2">
<EndProperty Name="Table1">
<ScalarProperty Name="Table1Key" ColumnName="Table1Key" /></EndProperty>
<EndProperty Name="Table2">
<ScalarProperty Name="Table2Key" ColumnName="Table2Key" />
<ScalarProperty Name="Table2OtherColumn" ColumnName="Table2OtherColumn" />
</EndProperty></AssociationSetMapping>
<EntityType Name="Table2">
<Key>
<PropertyRef Name="Table2Key" />
</Key>
<Property Name="Table2Key" Type="int" Nullable="false" />
<Property Name="Table2OtherColumn" Type="int" Nullable="false" />
...other properties...
</EntityType>