Saturday, 21 October 2017

MVC - fix error - Cannot implicitly convert type 'System.Data.Entity.Core.Objects.ObjectResult' to 'class'

Watch this example on YouTube


Cannot implicitly convert type
'System.Data.Entity.Core.Objects.ObjectResult<MVCDropDownListDBFirst.Models.SelectOrders_Result>'
to 'MVCDropDownListDBFirst.Models.SelectOrders_Result'

to fix it replace
model.or = db.SelectOrders();

with 
model.or = db.SelectOrders().FirstOrDefault();

No comments:

Post a Comment