3

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. 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)". (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).

 <add name="TransactionEF" 
 connectionString="some connection string" 
 providerName="System.Data.EntityClient" />

EDMX Connectionstring 'name'

Value cannot be null. Parameter name: source

Getting Error The argument 'nameOrConnectionString' cannot be null, empty or contain only white space with Azure Database

Here is my 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... 
Myre Van
  • 33
  • 1
  • 1
  • 4
  • Are you indeed using EDMX? Maybe go trough the properties window and look for an empty Name (or EntityName, SetName, whatever) – H H Oct 17 '17 at 14:23
  • Since the table name is the same as the class name, couldn't you just omit the `Table` annotation altogether? – Baksteen Oct 17 '17 at 14:29

2 Answers2

4
 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

You should look for any [Table] or [Table("")] in your project.

H H
  • 263,252
  • 30
  • 330
  • 514
0

Perhaps you have an empty Foreignkey attribute like

[ForeignKey("")]

Please have a look.

Venugopal M
  • 2,280
  • 1
  • 20
  • 30