5

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?

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

Wow - mind blown! Well, after your answer I searched some more since I had a better idea what to look for and found this other Q/A - stackoverflow.com/questions/3521497/… . Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.