本文介绍了对于EntityType错误,找不到EF映射和元数​​据信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用Entity Framework 4.0 RC时遇到异常。
我的实体框架模型封装在一个私人程序集中,名字是Procurement.EFDataProvider,我的POCO类在另一个程序集中Procurement.Core
Core(Business Logic)和EFDataProvider(Data Access)之间的关系有一个名为DataProvider的工厂

I have encountered an exception when I use Entity Framework 4.0 RC.My Entity Framework model is encapsulated in a private assembly who's name is Procurement.EFDataProvider and my POCO classes are inside of another assembly Procurement.CoreThe relation between Core(Business Logic)and EFDataProvider(Data Access) is with a factory named DataProvider

所以当我尝试创建一个对象集

so when I try to create an objectset

objectSet = ObjectContext.CreateObjectSet<TEntity>();

我收到错误:


推荐答案

对于处理错误的任何人,我认为值得一提的是我发现导致这个(非常无益)错误的一些场景:

For anyone else dealing with the error, I think it's worth mentioning some scenarios that I've found that cause this (extremely unhelpful) error:


  • 拼写错误的属性(区分大小写!)

  • POCO类中缺少属性

  • POCO和实体类型(例如,int而不是long)

  • 枚举在POCO中(EF根据我的理解现在不支持枚举)

  • Misspelled properties (case-sensitive!)
  • Properties missing in the POCO class
  • Type mismatches between the POCO and entity-type (e.g., int instead of long)
  • Enums in the POCO (EF doesn't support enums right now as I understand)

可能还有其他原因。

HTH

这篇关于对于EntityType错误,找不到EF映射和元数​​据信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 15:45