Why any class with EdmEntityTypeAttribute causes runtime error even if it's not used?
I created ADO.NET Entity Data Model. Let's say that it generated the code below:
namespace MyEntities
{
//Contexts
...
[EdmEntityTypeAttribute(NamespaceName="Entities", Name="table1")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
开发者_StackOverflow中文版 public partial class table1 : EntityObject{...}
}
Any manipulation on it works fine. For example
var cxt = new SPEntities();
var res = (from t in cxt.table1
select t).ToList();
But if I add ANY class with attribute [EdmEntityTypeAttribute]
within DIFFERENT namespace from table1 class, but in the SAME assembly that table1 class is located, so I get runtime errors like: The type doesn't have any key members.
, "Schema specified is not valid.
Let's say I add this class:
namespace ANY_NAMESPACE
{
[EdmEntityTypeAttribute]
public class ANY_CLASS
{
}
}
Why I get those kind errors if I even don't use ANY_CLASS class?
It looks like ADO.NET Entity engine passes through all classes with [EdmEntityTypeAttribute]
attribute in the ASSEMBLY before it execute the code and checks those classes for correct construction even if they aren't used. Am I right? If I do, why it does it?
Thank you
精彩评论