开发者

Entity Framework Code First and Database First Bug/Conflict

I have two projects in a VS 2010 solution: Data and DataForm. In my Data project I have both a Code first and Database first version of the same data model (e.g. DataPoco and DataDb). These classes have the same exact entity names within them, etc... These two versions are each in their own namespace: DataDb is in Data and DataPoco is in Data.Poco.

In my DataForm project I have the following code:

DataPoco context = new DataPoco(); //Data.Poco.DataPoco
foreach(var u in context.Urls)     //Data.Poco.Url
{
    //do stuff with u.
}

I get the following error when context.Urls is enumerated (and loaded due to lazy-loading):

Could not find the conceptual model type for 'Data.Url'.

Why am I getting an error about an entity in the OTHER version (e.g. how can I get an error about Data.Url when I'm 开发者_开发知识库enumerating Data.Poco.Url)? Is there something about code first that is making it pick up the Database first entity classes in another namespace but in the same project? Is this a bug in Code First or my fault?


Entity Framework does not use the namespace as part of the name - entity names themselves must be unique.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜