4

I am getting this error:

Sdl.Web.Common.DxaException: No semantic mapping found between Schema 810 (http://www.sdl.com/web/schemas/core:Item) and model type 'Sdl.Web.Common.Models.EntityModel'

I am working without the Core and I have created my Page, Entity and Region Views. I have a simple Schema/Model (Item) but I am getting the error when I run the application. I think the issue is in my Schema but I am not sure what I need to do to correct this.

1 Answer 1

2

The error message implies that your View Model has a (semantic) property of type EntityModel, which is an abstract base class.

It is fine to have such a property (mapped to a Component Link field), but since it is not possible to instantiate an abstract class, the model mapping has to find a suitable concrete sublass. It uses the semantic mapping on Schema/type level for that purpose.

Concretely, you must have a registered View Model type which maps to the Schema of the linked Component.

The error message shows that the semantic type name of the Schema is Item in the DXA Core Vocabulary (probably the root element name of your Schema is Item). Now you need a registered View Model type which is called Item or is annotated with [SemanticEntity(EntityName="Item"].

2
  • Thanks RIck, exactly right. I registered the View Model incorrectly and when I updated to: RegisterViewModel("Item", typeof(Item)); it worked. Commented May 18, 2017 at 20:49
  • 1
    Do you really have a View called "Item" for that View Model? Often, this is not the case for such embedded View Models. In that case, you can also use RegisterViewModel(typeof(Item)); Commented May 19, 2017 at 6:05

Your Answer

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

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