Inside Tridion 2013-SP1 with DD4T template 2.0.8
All our schema's Root element name are the same (e.g. schema Content has a root element of "Content" and schema Accordion List has a root element of "Content" too)
So, in our .net MVC code we are implementing viewModel. Below is the code for AccordionList viewModel.
[ContentModel("Content", true)]
public class AccordionList : ViewModelBase, IRenderableViewModel
{
[TextField(FieldName = "title")]
public string title { get; set; }
[TextField(FieldName = "description")]
public string description { get; set; }
[RenderData]
public IRenderData RenderData { get; set; }
}
Then here is the code for Content ViewModel.
[ContentModel("Content", true)]
public class Content : ViewModelBase, IRenderableViewModel
{
[TextField(FieldName = "title")]
public string title { get; set; }
[TextField(FieldName = "body")]
public string description { get; set; }
[RenderData]
public IRenderData RenderData { get; set; }
}
When we run the website we get this error message: The model item passed into the dictionary is of type 'DD4T.SampleWebSite.Models.Component.AccordionList', but this dictionary requires a model item of type 'DD4T.SampleWebSite.Models.Component.Content'.
I think because they have the same root element schema and that AccordionList is the first viewModel in the list even if it really need the viewModel Content. The AccordionList is the one that gets register.
So my question now is that is there anyway we can fix the issue without changing tridion schema root element name?