LINQ + EntityFunctions in asp.net mvc

后端 未结 2 1084
陌清茗
陌清茗 2020-12-21 13:52

I have such code using EntityFramework Alpha3 (from nuget):

class Member
{
    [Key]
    public int Key { get; set; }
    public string Forename { get; set;         


        
2条回答
  •  春和景丽
    2020-12-21 14:34

    I suspect that in the case of your ASP.NET app, you also have a reference to System.Data.Entity, and that you are using the EntityFunctions class defined System.Data.Entity.

    However, Entity Framework 6 has removed the dependency on System.Data.Entity and has redefined all necessary classes for that purpose inside of the EntityFramework assembly.

    Meaning that, in the case of your console app, I am guessing that either by design (System.Data.Entity is not referenced) or by accident (System.Data.Entity is referenced but the EntityFunctions class is taken from EntityFramework.dll), the correct version of EntityFunctions (from EntityFramework.dll) is taken.

    If you are using any version of Entity Framework 6, make sure that you are using the EntityFunctions class that can be found in EntityFramework.dll, not the one in System.Data.Entity. Source code of EntityFunctions.cs in Entity Framework 6

    Actually, if you use Entity Framework 6, I would recommend removing all and any references to System.Data.Entity - in order to avoid any future confusion and mistake.

提交回复
热议问题