We are creating all-new schemas/views/models as per our project's requirements. One of our schemas is a bit complex because of the vast requirements that we have. Here is a basic structure:
Schema 1 :
1st field: title
2nd field: component link to schema 2, schema 3, media item or an ECL item
Now, when we create a component using schema 1, schema 2 and schema 3, everything works fine and the view is able to render everything correctly. But the moment we include a media item or an ECL item, our model starts throwing an error "No Semantic mapping between schema 2 and media item" Or "No semantic mapping between schema 3 and media item".
There is no direct relationship between schema 2/3 and media item/ECL item. They are just allowed schemas for schema 1.
We have registered all the needed views or models appropriately after looking at this.
Any suggestions?
Update 1:
While debugging, we see that the error is thrown in SemanticSchema.cs -> function GetModelTypeFromSemanticMapping and the reason is that the baseModelType being passed and the mappedModelTypes do not match. The mappedModelType is actually correct and is what it should be as per the component created. But the baseModelType being passed is incorrect and belongs to one of the other schemas (Schema 3, in this case).
Update 2: I had simplified the scenario a bit in my original question but here is the structure that we have: Schema 1:
public class Menu : EntityModel
{
[SemanticProperty("me:menuItems")]
public List<MenuItems> menuItems { get; set; }
}
Menu Items:
public class MenuItems : EntityModel
{
[SemanticProperty("me:menuItemDetails")]
public MenuLink menuItemDetails { get; set; }
[SemanticProperty("me:columns")]
public List<EmbeddedModels.Columns> columns { get; set; }
}
MenuItemDetails is fine and we are able to fetch all the information related to it, the problem is with columns:
public class Columns : EntityModel
{
[SemanticProperty("me:columnItem")]
public ContentSimple ContentSimple { get; set; }
[SemanticProperty("me:columnItem")]
public Submenu Submenu { get; set; }
[SemanticProperty("me:columnItem")]
public MediaItem mediaItem { get; set; }
[SemanticProperty("me:columnItem")]
public ECLItem EclItems { get; set; }
}
ContentSimple does have another field for Media Item and EclItem I tried to write a class similar to the Teaser class and basically replaced columns class with that. But it stopped mapping the content completely.
EntityModel
instead of several properties of different types which map to the same CM field.