0

I'm using the Sample DD4T 2.0 Application from Katerina and updated the references to DD4T 2.2. Running the sample app I get the following error:

Could not find view model for item with Publication ID 'DD4T.ContentModel.ComponentPresentation'

Do I need to update some of the code to work with 2.2 or update the config?

1 Answer 1

2

This error means that the ViewModelFactory is unable to find a suitable ViewModel for your component presentation. The most common causes for this are:

  • The root element name does not match the first parameter in the ContentModel attribute (it's case-sensitive)

  • The second parameter in the ContentModel attribute is set to false (you can set it to false for classes representing embedded schemas or linked schemas, but you must set it to false for component presentations)

  • The ViewModel class does not implement IViewModel

Also note that the root element names for your schemas should be unique, otherwise DD4T will never be able to find a matching ViewModel.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.