EF4 + MVCScaffolding

Feb 23, 2011 at 6:00 AM
Edited Feb 23, 2011 at 6: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 11:32 PM

AGREED!!

 

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 3, 2011 at 12:04 AM

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 3, 2011 at 12:17 AM
Edited Mar 3, 2011 at 12:24 AM

bingo... found the answer...

http://blogs.msdn.com/b/adonet/archive/2010/12/06/ef-feature-ctp5-model-amp-database-first-with-dbcontext.aspx

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...