实体框架4.0 POCO SaveChanges错误

时间:2012-09-10 18:47:26

标签: c# entity-framework

当我尝试使用POCO实体调用Entity Framework 4.0中的SaveChanges()时,出现此错误:

System.InvalidOperationException occurred
  HResult=-2146233079
  Message=No views were found in assemblies or could be generated for Table 'FnclAttribute'.
  Source=System.Data.Entity
  StackTrace:
       at System.Data.Mapping.StorageMappingItemCollection.ViewDictionary.GetGeneratedView(EntitySetBase extent, MetadataWorkspace workspace, StorageMappingItemCollection storageMappingItemCollection)
       at System.Data.Mapping.Update.Internal.UpdateTranslator.<ProduceDynamicCommands>d__0.MoveNext()
       at System.Linq.Enumerable.<ConcatIterator>d__71`1.MoveNext()
       at System.Data.Mapping.Update.Internal.UpdateCommandOrderer..ctor(IEnumerable`1 commands, UpdateTranslator translator)
       at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
       at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
       at Manatron.AR.Model.Financial.FinancialRepository.PersistFinancialSources(IEnumerable`1 financialSources) in C:\CorpDev\GRM\Dev\AR\AR.Model\Financial\FinancialRepository.cs:line 66
  InnerException: 

对于App.Config文件中的csdl和ssdl,我似乎有正确的映射。我用来调用这个保存操作的代码是:

public void PersistFinancialSources( IEnumerable<IFinancialSource> financialSources )
{
  using (FinancialDataContext financialDataContext = _financialDataContextFactory.Create())
  {
    foreach (IFinancialSource financialSource in financialSources)
    {
      var financialSourceEntity = financialSource as FinancialSource;

      if (financialSourceEntity != null)
      {
        IEnumerable<IFinancialAttribute> newFinancialAttributes =
          from financialAmount in financialSource.FinancialAmounts
          where financialAmount.FinancialAttribute.Id < 0
          select financialAmount.FinancialAttribute;

        foreach (FinancialAttribute financialAttribute in newFinancialAttributes)
        {
          financialDataContext.FinancialAttributes.AddObject(financialAttribute);
        }
      }
    }

    financialDataContext.SaveChanges(SaveOptions.None);
  }
}

有什么问题可能是什么问题?我没有找到关于这个错误的信息......

0 个答案:

没有答案