The mapping of CLR type to EDM type is ambiguous with EF 6 & 5?

后端 未结 14 1619
长发绾君心
长发绾君心 2020-11-27 05:38

Please any one can help me to fix this error?

Schema specified is not valid. Errors:

The mapping of CLR type to EDM type is ambiguous because mult

14条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 06:16

    In some cases this is more of a symptom than the actual problem. For me, it usually pops up when I try to call a function inside a Linq query without calling .ToList() first.

    E.g. the error that brought me here was caused because I did this:

    var vehicles = DB.Vehicles.Select(x => new QuickSearchResult()
    {
        BodyText = x.Make + " " + x.Model + "
    " + "VIN: " + x.VIN + "
    " + "Reg: " + x.RegistrationNumber +"
    " + x.AdditionalInfo type = QuickSearchResultType.Vehicle,//HERE. Can't use an enum in an IQueryable. UniqueId = x.VehicleID });

    I had to call .ToList(), then iterate through each item and assign the type to it.

提交回复
热议问题