用户代码未处理ArgumentException:参数'name'不能为null,为空或仅包含空格

时间:2019-03-18 08:14:40

标签: vb.net entity-framework

我想使用实体显示我的表内容。在此之前,我从数据库更新了模型。这是我的代码

Dim b As New myEntities
Dim lld1 = b.LLD1_Header.ToList()

当我在Dim lld1 = b.LLD1_Header.ToList()上时发生错误,它说“参数'name'不能为null,为空或仅包含空格。” < / p>

.config文件中的我的连接字符串:

<add name="myEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=10.65.69.103;initial catalog=ANZLLD;user id=llduser;password=P@ssw0rd1;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

这是我的堆栈跟踪:

    at System.Data.Entity.Utilities.Check.NotEmpty(String value, String parameterName)
   at System.Data.Entity.Core.Metadata.Edm.EdmProperty..ctor(String name, TypeUsage typeUsage)
   at System.Data.Entity.Core.Metadata.Edm.Converter.ConvertToProperty(StructuredProperty somProperty, DbProviderManifest providerManifest, ConversionCache convertedItemCache, Dictionary`2 newGlobalItems)
   at System.Data.Entity.Core.Metadata.Edm.Converter.ConvertToEntityType(SchemaEntityType element, DbProviderManifest providerManifest, ConversionCache convertedItemCache, Dictionary`2 newGlobalItems)
   at System.Data.Entity.Core.Metadata.Edm.Converter.LoadSchemaElement(SchemaType element, DbProviderManifest providerManifest, ConversionCache convertedItemCache, Dictionary`2 newGlobalItems)
   at System.Data.Entity.Core.Metadata.Edm.Converter.ConvertToEntitySet(EntityContainerEntitySet set, DbProviderManifest providerManifest, ConversionCache convertedItemCache, Dictionary`2 newGlobalItems)
   at System.Data.Entity.Core.Metadata.Edm.Converter.ConvertToEntityContainer(EntityContainer element, DbProviderManifest providerManifest, ConversionCache convertedItemCache, Dictionary`2 newGlobalItems)
   at System.Data.Entity.Core.Metadata.Edm.Converter.LoadSchemaElement(SchemaType element, DbProviderManifest providerManifest, ConversionCache convertedItemCache, Dictionary`2 newGlobalItems)
   at System.Data.Entity.Core.Metadata.Edm.Converter.ConvertSchema(Schema somSchema, DbProviderManifest providerManifest, ConversionCache convertedItemCache, Dictionary`2 newGlobalItems)
   at System.Data.Entity.Core.Metadata.Edm.Converter.ConvertSchema(IList`1 somSchemas, DbProviderManifest providerManifest, ItemCollection itemCollection)
   at System.Data.Entity.Core.Metadata.Edm.EdmItemCollection.LoadItems(DbProviderManifest manifest, IList`1 somSchemas, ItemCollection itemCollection)
   at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError, IDbDependencyResolver resolver, DbProviderManifest& providerManifest, DbProviderFactory& providerFactory, String& providerInvariantName, String& providerManifestToken, Memoizer`2& cachedCTypeFunction)
   at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.LoadStoreCollection(EdmItemCollection edmItemCollection, MetadataArtifactLoader loader)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.<>c__DisplayClass5.<>c__DisplayClass7.<GetMetadataWorkspace>b__4()
   at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.LoadAndCheckItemCollection[T](Func`1 itemCollectionLoader)
   at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
   at System.Lazy`1.get_Value()
   at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetItemCollection(DataSpace dataSpace, Boolean required)
   at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetItemCollection(DataSpace dataSpace)
   at System.Data.Entity.Core.Objects.ObjectContext.InitializeMappingViewCacheFactory(DbContext owner)
   at System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor, ObjectQueryExecutionPlanFactory objectQueryExecutionPlanFactory, Translator translator, ColumnMapFactory columnMapFactory)
   at System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel()
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   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.GetEnumerator()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at LLD_LLD_1_LLD1_Header.StoreView_ReadData(Object sender, StoreReadDataEventArgs e) in C:\Temp\Felix Nitip\v3 180319\Source Code\Web\lld\lld 1\LLD1_Header.aspx.vb:line 405
   at Ext.Net.SyncStoreBase.RaiseAjaxPostBackEvent(String eventArgument)

无论如何我应该怎么解决呢?我已经多次删除和删除模型,仍然出现此错误。您的回答将不胜感激。谢谢

2 个答案:

答案 0 :(得分:0)

检查项目中是否有[Table]或[Table(“”)]] Dto属性属性。

答案 1 :(得分:0)

我通过在生成模型数据库时选择必要的表和视图来解决此问题