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
Another possible issue is, if you are using code-first and your entity type is defined in a separate assembly to where the context is define and you haven't added any custom mappings to the OnModelCreating(DbModelBuild modelBuilder)
method, then EF seems to ignore the data annotations.
Solution:
Add modelBuilder.Entity<YourEntityType>();
to the OnModelCreating(DbModelBuild modelBuilder)
method.
Related post.
I have also seen it when the connection string is not specified in the config file.
My problem was I had edited the T4 template to exclude the replication field named "msrepl_tran_version". This caused the database to not match the generated classes which can causes this error message. Just make sure your database and classes match.
Just check the property spelling with the model
Not directly related to the above, but if you get this error message and you have mixed a POCO and a regular model: bad idea!
See also the comment from JRoppert at EF4 POCO (not using T4): Mapping and metadata information could not be found for EntityType (thanks JRoppert!)
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:
There might be other causes as well.
HTH