EF 5.0 Code First / DbContext でエンティティをクエリしています。次のエラーが表示されます。
列名「RetainedEarningsAccount_Key」が無効です。列名「PLSummaryAccount_Key」が無効です。
ただし、これらのフィールドはどちらもモデルには存在しません。ここでデフォルトの構成/マッピングが行われていると思いますが、それが何であるかはわかりません。問題のモデル クラスは次のとおりです。
public GLEntity()
{
this.AccessEntities = new HashSet<AccessEntity>();
this.BankAccountGLAccounts = new HashSet<BankAccountGLAccount>();
this.BatchRestrictionEntities = new HashSet<BatchRestrictionEntity>();
this.BudgetVersions = new HashSet<BudgetVersion>();
this.CalendarCrossRefs = new HashSet<CalendarCrossRef>();
this.ConsolDetails = new HashSet<ConsolDetail>();
this.ConsolHeaders = new HashSet<ConsolHeader>();
this.DefaultBudgetVersions = new HashSet<DefaultBudgetVersion>();
this.Departments = new HashSet<Department>();
this.ExpenseCodeDetails = new HashSet<ExpenseCodeDetail>();
this.GLAccounts = new HashSet<GLAccount>();
this.Journals = new HashSet<Journal>();
this.PostingRules = new HashSet<PostingRule>();
this.Processes = new HashSet<Process>();
this.Properties = new HashSet<Property>();
this.RecurringJournals = new HashSet<RecurringJournal>();
this.RecurringTransactionGLs = new HashSet<RecurringTransactionGL>();
this.EntitiesAlternate = new HashSet<GLEntity>();
this.GLIntercompaniesDestinationEntities = new HashSet<GLIntercompany>();
this.GLIntercompaniesSourceEntities = new HashSet<GLIntercompany>();
this.TransGLs = new HashSet<TransGL>();
}
public System.Guid Key { get; set; }
public string EntityID { get; set; }
public string Description { get; set; }
public Nullable<short> CurrentFiscalYear { get; set; }
public Nullable<short> CurrentPrd { get; set; }
public string EntityType { get; set; }
public string AllowPostingYN { get; set; }
public string NextJournal { get; set; }
public Nullable<System.Guid> CompanyKey { get; set; }
public Nullable<System.Guid> RetainedEarningsAcctKey { get; set; }
public Nullable<System.Guid> PLSummaryAcctKey { get; set; }
public string AccountingType { get; set; }
public string UserCreated { get; set; }
public System.DateTime Created { get; set; }
public string UserEdited { get; set; }
public Nullable<System.DateTime> Edited { get; set; }
public Nullable<System.Guid> AlternateEntityKey { get; set; }
public string TrackJobs { get; set; }
public string TrackUnits { get; set; }
public virtual ICollection<AccessEntity> AccessEntities { get; set; }
public virtual ICollection<BankAccountGLAccount> BankAccountGLAccounts { get; set; }
public virtual ICollection<BatchRestrictionEntity> BatchRestrictionEntities { get; set; }
public virtual ICollection<BudgetVersion> BudgetVersions { get; set; }
public virtual ICollection<CalendarCrossRef> CalendarCrossRefs { get; set; }
public virtual Company Company { get; set; }
public virtual ICollection<ConsolDetail> ConsolDetails { get; set; }
public virtual ICollection<ConsolHeader> ConsolHeaders { get; set; }
public virtual ICollection<DefaultBudgetVersion> DefaultBudgetVersions { get; set; }
public virtual ICollection<Department> Departments { get; set; }
public virtual ICollection<ExpenseCodeDetail> ExpenseCodeDetails { get; set; }
public virtual ICollection<GLAccount> GLAccounts { get; set; }
public virtual ICollection<Journal> Journals { get; set; }
public virtual ICollection<PostingRule> PostingRules { get; set; }
public virtual ICollection<Process> Processes { get; set; }
public virtual ICollection<Property> Properties { get; set; }
public virtual ICollection<RecurringJournal> RecurringJournals { get; set; }
public virtual ICollection<RecurringTransactionGL> RecurringTransactionGLs { get; set; }
public virtual ICollection<GLEntity> EntitiesAlternate { get; set; }
public virtual GLEntity EntityAlternate { get; set; }
public virtual ICollection<GLIntercompany> GLIntercompaniesDestinationEntities { get; set; }
public virtual ICollection<GLIntercompany> GLIntercompaniesSourceEntities { get; set; }
public virtual ICollection<TransGL> TransGLs { get; set; }
public virtual GLAccount RetainedEarningsAccount { get; set; }
public virtual GLAccount PLSummaryAccount { get; set; }
}
そして、ここにマッピングがあります:
public GLEntity_Mapping()
{
this.HasKey(t => t.Key);
this.ToTable("tblEntity");
this.Property(t => t.Key).HasColumnName("KeyGUID");
this.Property(t => t.EntityID).HasColumnName("EntityID").IsUnicode(false).HasMaxLength(10);
this.Property(t => t.Description).HasColumnName("Description").IsUnicode(false).HasMaxLength(50);
this.Property(t => t.CurrentFiscalYear).HasColumnName("CurrentFiscalYear");
this.Property(t => t.CurrentPrd).HasColumnName("CurrentPrd");
this.Property(t => t.EntityType).HasColumnName("EntityType").IsUnicode(false).IsFixedLength().HasMaxLength(1);
this.Property(t => t.AllowPostingYN).HasColumnName("AllowPostingYN").IsUnicode(false).IsFixedLength().HasMaxLength(1);
this.Property(t => t.NextJournal).HasColumnName("NextJournal").IsUnicode(false).HasMaxLength(20);
this.Property(t => t.CompanyKey).HasColumnName("Company");
this.Property(t => t.RetainedEarningsAcctKey).HasColumnName("RetainedEarningsAcct");
this.Property(t => t.PLSummaryAcctKey).HasColumnName("PLSummaryAcct");
this.Property(t => t.AccountingType).HasColumnName("AccountingType").IsUnicode(false).IsFixedLength().HasMaxLength(1);
this.Property(t => t.UserCreated).HasColumnName("UserCreated").IsRequired().IsUnicode(false).HasMaxLength(50);
this.Property(t => t.Created).HasColumnName("Created");
this.Property(t => t.UserEdited).HasColumnName("UserEdited").IsUnicode(false).HasMaxLength(50);
this.Property(t => t.Edited).HasColumnName("Edited");
this.Property(t => t.AlternateEntityKey).HasColumnName("AlternateEntity");
this.Property(t => t.TrackJobs).HasColumnName("TrackJobs").IsUnicode(false).IsFixedLength().HasMaxLength(1);
this.Property(t => t.TrackUnits).HasColumnName("TrackUnits").IsUnicode(false).IsFixedLength().HasMaxLength(1);
this.HasOptional(t => t.Company).WithMany(t => t.Entities).HasForeignKey(d => d.CompanyKey);
this.HasOptional(t => t.EntityAlternate).WithMany(t => t.EntitiesAlternate).HasForeignKey(d => d.AlternateEntityKey);
}
存在しないプロパティでエラーが発生するのはなぜですか?