[英]The argument 'name' cannot be null, empty or contain only white space
I am getting the below errors.我收到以下错误。 I tried googling the issue.
我试着用谷歌搜索这个问题。 But none of the post I have found have helped me.
但是我发现的帖子都没有帮助我。
EDIT:Per Henk's reply.编辑:根据 Henk 的回复。 the Table in question.
有问题的表。
[Table("TransactionDetail")]
public partial class TransactionDetail
{
[Key, Column(Order = 1), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long TransactionDetailId { get; set; }
public string TransactionName { get; set; }
public string TransactionValue { get; set; }
public virtual OriginalTransaction OriginalTrans { get; set; }
}
The Other Partial.其他部分。
public partial class TransactionDetail
{
public Transaction trans;
}
More specifically the error occur when I use a LINQ "MyContext.SomeDB.Find(x)".更具体地说,当我使用 LINQ“MyContext.SomeDB.Find(x)”时会发生错误。 (if this helps).
(如果这有帮助)。
Some post that I have looked at that seems to fit my issue but not help me solve it are:我看过的一些帖子似乎适合我的问题但不能帮助我解决它是:
Connection String: (in.config file).连接字符串:(in.config 文件)。
<add name="TransactionEF"
connectionString="some connection string"
providerName="System.Data.EntityClient" />
EDMX Connectionstring 'name' EDMX 连接字符串“名称”
Value cannot be null. Parameter name: source 取值不能为null 参数名称:source
Getting Error The argument 'nameOrConnectionString' cannot be null, empty or contain only white space with Azure Database 获取错误参数“nameOrConnectionString”不能为 null,为空或仅包含 Azure 数据库的空格
Here is my dbContext class.这是我的 dbContext class。
public partial class TransactionEF : DbContext
{
public TransactionEF()
: base("name=TransactionEF")
{
}
...
}
System.ArgumentException: The argument 'name' cannot be null, empty or contain only white space.
at System.ComponentModel.DataAnnotations.Schema.TableAttribute..ctor(String name)
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectGetAttributes(Type type)
at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetAttributes()
at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetAttributes()
at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetAttributes()
at System.ComponentModel.DataAnnotations.AssociatedMetadataTypeTypeDescriptor.GetAttributes()
at System.Data.Entity.ModelConfiguration.Utilities.AttributeProvider.GetAttributes(Type type)
at System.Data.Entity.ModelConfiguration.Conventions.TypeAttributeConfigurationConvention`1.<.ctor>b__1(Type t)
at System.Data.Entity.ModelConfiguration.Conventions.TypeConventionWithHavingBase`1.ApplyCore(Type memberInfo, ModelConfiguration modelConfiguration)
at System.Data.Entity.ModelConfiguration.Conventions.TypeConventionBase.Apply(Type memberInfo, ModelConfiguration modelConfiguration)
at System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.ApplyModelConfiguration(Type type, ModelConfiguration modelConfiguration)
at System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.ApplyModelConfiguration(Type type, ModelConfiguration modelConfiguration)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type)
at System.Data.Entity.ModelConfiguration.Mappers.NavigationPropertyMapper.Map(PropertyInfo propertyInfo, EntityType entityType, Func`1 entityTypeConfiguration)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type)
at System.Data.Entity.ModelConfiguration.Mappers.NavigationPropertyMapper.Map(PropertyInfo propertyInfo, EntityType entityType, Func`1 entityTypeConfiguration)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type)
at System.Data.Entity.ModelConfiguration.Mappers.NavigationPropertyMapper.Map(PropertyInfo propertyInfo, EntityType entityType, Func`1 entityTypeConfiguration)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type)
at System.Data.Entity.ModelConfiguration.Mappers.NavigationPropertyMapper.Map(PropertyInfo propertyInfo, EntityType entityType, Func`1 entityTypeConfiguration)
at System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type)
at System.Data.Entity.DbModelBuilder.MapTypes(EdmModel model)
at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
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.get_InternalContext()
at System.Data.Entity.Internal.Linq.InternalSet`1.Find(Object[] keyValues)
at MyCompany...
at MyCompany...
at MyCompany...
at System.ComponentModel.DataAnnotations.Schema.TableAttribute..ctor(String name)
You didn't post the relevant part of the code. 您没有发布代码的相关部分。 It's not about this constructor.
这不是关于这个构造函数。
Check out TableAttribute Class 查看TableAttribute类
You should look for any [Table]
or [Table("")]
in your project. 您应该在项目中查找任何
[Table]
或[Table("")]
。
Perhaps you have an empty Foreignkey attribute like也许你有一个空的外键属性,比如
[ForeignKey("")]
Please have a look.请看一看。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.