"Metadata information not found" while using EF4's POCO Template?
- by ladenedge
I just installed the POCO Template for EF4. I have a single entity in my model, AnnouncementText, and the T4 files seem to be properly generated. Attempting to access this new entity is throwing the following error when I access the auto-generated property MyObjectContext.AnnouncementTexts:
InvalidOperationException: Mapping and metadata information could not be found for EntityType 'MyNamespace.AnnouncementText'.
The properties on the AnnouncementText POCO seem to match up with the columns in the database, and I haven't changed any of the auto-generated code.
The stack trace is:
at System.Data.Objects.ObjectContext.GetTypeUsage(Type entityCLRType)
at System.Data.Objects.ObjectContext.GetEntitySetForNameAndType(String entitySetName, Type entityCLRType, String exceptionParameterName)
at System.Data.Objects.ObjectContext.CreateObjectSet[TEntity](String entitySetName)
at MyNamespace.MyObjectContext.get_AnnouncementTexts() in C:\<snip>\MyObjectContext.Context.cs:line 65
at MyNamespace.Class1.Main() in C:\<snip>\Class1.cs:line 14
If I delete the .tt files from the solution and enable code generation on the model, I am able to access the property without issue.
Here's my code, in case that might help:
using (var context = new MyObjectContext())
foreach (var at in context.AnnouncementTexts)
Console.WriteLine(at.Title);
Any ideas on what might be wrong?