EF4 + MVCScaffolding

Feb 23, 2011 at 5:00 AM
Edited Feb 23, 2011 at 5:00 AM

Any time I try to use MVCScaffolding on a model created with EF4 (no matter the simplicity), I end up getting an error when I try to view a view for that controller.  The error is:

The type 'MvcApplication1.Models.Cake' is not a supported entity type.

I can't figure out why - there doesn't seem to be anything wrong with the generated controller or view as far as I can tell.


Feedback?  Has anyone else had success?

Mar 2, 2011 at 10:32 PM



I dont know what the cause of this is... i actualy go into the repo ad changed the DBContext to XYZEntities;


once i do that, i have to do minor changes to the repo, but id really like to know what the issue is or the trick to changing out the DBContext

Mar 2, 2011 at 11:04 PM

As best as I can understand at this point - the generated classes from the edmx cannot be used as an entity. After installing the ADO.NET C# POCO Entity Generator and generating the appropriate POCO class for my "cake" entity, everything seems to work fine. I'm still baffled by why the partial classes inheriting from "entityobject" can't be used as an entity, but at least have a workable solution to generate a quick prototype from a given database model.

Mar 2, 2011 at 11:17 PM
Edited Mar 2, 2011 at 11:24 PM

bingo... found the answer...


What you want to do is install the CTP5 exe and restart your computer... (or at least i had to)... once that was done i was able to "Add Code Generation" and do the EF-CodeFirst... Pressed run and i was good to go... Let me know if that works for you too..


BTW, when you rerun the scaffold, make sure you arnt running lol... kept crashing until i stopped and reran the last line in the package manager...