Showing posts with label Model conflicts with the declaration error. Show all posts
Showing posts with label Model conflicts with the declaration error. Show all posts

Tuesday, March 25, 2014

FIX: 'Model' conflicts with the declaration 'System.Web.Mvc.WebViewPage.Model'

I suddenly started receiving this error in one of my razor view. The error message was -
'Model' conflicts with the declaration 'System.Web.Mvc.WebViewPage<TModel>.Model'

This error is caused if you use "Model" instead of "model" in one or more lambda expressions (predicates) in your view.

Perform a case-sensitive search for "Model =>", and its very much possible that you may notice this in one or more lambda expressions,
For example,
@Html.EditorFor(Model => Model.BirthDate)
This should be actually, @Html.EditorFor(model => model.BirthDate)
Correcting this should fix the Model conflict error for you in your view.