在我的工作場所,我們共享使用Entity Framework 6.0進行數據庫操作的項目。實體框架6生成錯誤的上下文代碼
在存儲庫中,我看到MyModel.Context.cs
文件中的修改(添加了一個函數)。
從這使用塊:
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Linq;
它改成這樣:
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Core.Objects;
using System.Data.Objects.DataClasses;
using System.Linq;
[EdmFunction("MyEntities", "DbFunction1")]
public virtual IQueryable<DbFunction1_Result> DbFunction1(Nullable<System.Guid> id)
{
//some code
return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<DbFunction1_Result>("[MyEntities].[DbFunction1](@id)", parameter);
}
我更新了我的工作副本並將其編譯。
但是,每當我用Update model from database
,我的代碼更改回本:
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Linq;
我們都通過的NuGet使用EF 6.0。
當我檢查的EntityFramework DLL的屬性,我得到這個:
這是什麼原因?
[更新您的EDMX(或.tt)文件](https://msdn.microsoft.com/en-us/data/upgradeef6.aspx)。 – CodeCaster