2017-10-17 3 views
1

Ich erhalte die folgenden Fehler. Ich habe versucht, das Problem zu googeln. Aber keiner der Post, die ich gefunden habe, hat mir geholfen.Das Argument 'Name' darf nicht null, leer sein oder nur Leerzeichen enthalten

EDIT: Per Henks Antwort. die Tabelle in Frage.

[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; } 
} 

Die anderen Teilweise.

Genauer gesagt tritt der Fehler auf, wenn ich ein LINQ "MyContext.SomeDB.Find (x)" verwende. (wenn das hilft).

noch einige Kleinigkeiten, die ich ausgesehen haben an das scheint mein Problem zu passen, aber nicht mir helfen, lösen sie sind:

Connection String: (in CONFIG-Datei).

<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

Hier ist meine DbContext Klasse.

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... 
+0

Verwenden Sie tatsächlich EDMX? Vielleicht durch das Eigenschaftenfenster gehen und nach einem leeren Namen (oder EntityName, SetName, was auch immer) suchen. –

+0

Da der Tabellenname derselbe wie der Klassenname ist, können Sie die Annotation 'Table' nicht einfach weglassen? – Baksteen

Antwort

2
at System.ComponentModel.DataAnnotations.Schema.TableAttribute..ctor(String name) 

Sie haben den entsprechenden Teil des Codes nicht veröffentlichen. Es geht nicht um diesen Konstruktor.

Check out TableAttribute Class

Sie für jede [Table] oder [Table("")] in Ihrem Projekt aussehen sollte.

+0

Ich kann den .TableAttribute-Konstruktor nicht finden. –

+0

@MyreVan Sie müssen sich alle ** Entitäten ansehen, nicht nur die, die Sie abfragen. – DavidG

+0

Dank @DavidG, einer der anderen Teiltöne hatte nichts in der [Tabelle (""]] –

Verwandte Themen