After a git merge of a branch that uses the Entity framework, using Entities on a different database have stopped working with the error "The member with identity 'Path.To.Class' does not exist in the metadata collection."
This error is encountered when the following line of code开发者_StackOverflow中文版 executes:
var databaseTable = database.CreateObject<Table>();
Looking online others solved this by verifying the files were named the same, etc. I have done this but with no luck. Where is this metadata stored and set and what can I do to fix it?
UPDATE: by manually merging in one file at a time, what seems to cause this error to start happening is when adding another .edmx file to the .csprodj file. Also, by deleting the other .edmx file it also started working again. In other words: including a second .edxm file in the same project is breaking the first! How can I solve this!
We were able to fix this by deleting the two .edmx and associated .tt files and then for each we:
- Created new ADO .NET Entity Data Model
- Kept all names automatically generated from importing from the database untouched
- Added code generation from the .edmx file itself and used ADO .NET EntityObject Generator (resulting in a single .tt file for each)
- Updated our code (need to access new entity names) and configuration files (change entity name for connection strings)
My guess is somewhere things got incompatible, particuarlly on how we added code generation items. Prior to this "delete everything and try again" solution we used to have multiple .tt files for a single .edmx file--but this is no longer the case.
精彩评论