Following on from this question here:Entity Framework Reverse Engineer using Power Tools – No Primary Keys
I’ve reverse engineered a database using Entity Framework Power Tools Beta 2.
This has created a large number of POCO’s and a mappings folder with the entity mappings.
When I attempt to create a controller using the Add Controller Dialog I get the following message box come up:
Unable to retrieve metadata for cruise model. One or more Validation errors were detected during model generation:
\tSystem.Data.Entity.EmdEntityTypes:: cruise table has no key defined. Define the key for this EntityType.
This repeats many times for all the related tables to the original one for which I was trying to create a controller.
The Controller itself is never created and on pressing OK I’m returned to the Add Controller Dialog.
The model in question definitley has a primary key defined in it’s mapping file:
// Primary Key
this.HasKey(t => t.cruise_ID);
What am I doing wrong?
How does the controller find the mapping classes?
I’ve been able to replicate the error your receive, and it’s related to trying to create a controller for the Model itself, rather than for the entity type.
The MVC scaffolding is designed to target an entity, then the related context – are you sure you’re selecting the right items in the drop down?
In This image: