Answered by:
Could not find the conceptual model type for

Question
-
When having an .edmx file with Code First using modelBuilder in OnModelCreating (overridden) there is an error when initializing the Context object saying: Could not find the conceptual model type for
This happens regardless. When removing the edmx file from the project, the error goes away.
Is there a way to add conceptual model for tables/entities in the edmx file without removing or changing the edmx file, or is it a way to turn off discovering of the conceptual model for entities described in the .edmx model?
Guess this is also related to the question "Can you have database first and code first in the same project?"
Tuesday, March 8, 2011 10:27 AM
Answers
-
Hi,
The short answer is no, if you are using the default code generation for an EDMX file then Code First (or any EF model that uses POCO classes) will not work in the same project. I've provided more detail in this thread; http://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/b87815ff-6569-4559-8268-7ae6433b8aa8.
If you were to swap and use the DbContext code generator for your edmx based model then this would work (the template is included with CTP5). This would work because that template generated POCO classes rather than the EntityObject based classes generated by the default template.
~Rowan
- Proposed as answer by Rowan MillerModerator Wednesday, March 9, 2011 11:29 PM
- Marked as answer by talisker1977 Thursday, March 10, 2011 7:13 AM
Wednesday, March 9, 2011 11:29 PMModerator
All replies
-
Hi,
The short answer is no, if you are using the default code generation for an EDMX file then Code First (or any EF model that uses POCO classes) will not work in the same project. I've provided more detail in this thread; http://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/b87815ff-6569-4559-8268-7ae6433b8aa8.
If you were to swap and use the DbContext code generator for your edmx based model then this would work (the template is included with CTP5). This would work because that template generated POCO classes rather than the EntityObject based classes generated by the default template.
~Rowan
- Proposed as answer by Rowan MillerModerator Wednesday, March 9, 2011 11:29 PM
- Marked as answer by talisker1977 Thursday, March 10, 2011 7:13 AM
Wednesday, March 9, 2011 11:29 PMModerator -
Has there been any progress on this issue? I'll (reluctantly) move it to another project for now, but it's kind of obnoxious. Still... another project is faster than code-first for all my entities.
Tuesday, October 4, 2011 4:18 PM -
Hi Rowan,
I am able to run the edmx (Model first) project under the Code first main project, but in that scenario only edmx codes is working which i placed under the Area.
And when i run Code First Codes i get this error:
Could not find the conceptual model type for 'MyMVC.Areas.Help.Models.sysdiagram'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Could not find the conceptual model type for 'MyMVC.Areas.Help.Models.sysdiagram'.Line 79: Line 80: Line 81: var ErrorCount = (from e in db.AppErrorsTrace
Please help me to understand what can be the issue? and how to fix it? Do you think is there anyway?
Thanks in advance.
Regards,
Amit
- Edited by microamit Monday, February 6, 2012 8:38 PM
Monday, February 6, 2012 8:37 PM