我試圖將表單值傳遞給存儲過程,將值插入到SQL Server表中。但是我發現了一個錯誤:通過存儲過程問題的MVC形式到數據庫:存儲過程無法執行,因爲它沒有映射到存儲的函數
function import 'appEntities.CreateUser' cannot be executed because its not mapped to a stored function.
在Google上搜尋它,我得到這個SO發佈Error calling Stored Procedures from EntityFramework,我已經試過利用它。但是,我沒有在我的.edmx
文件中爲我的存儲過程找到一個實體模型,如上面引用的SO解決方案所示。我的存儲過程是在我的上下文類,如下所示:
public virtual int CreateUser(string userLanID, string email)
{
var userLanIDParameter = userLanID != null ?
new ObjectParameter("UserLanID", userLanID) :
new ObjectParameter("UserLanID", typeof(string));
var emailParameter = email != null ?
new ObjectParameter("Email", email) :
new ObjectParameter("Email", typeof(string));
return((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("CreateUser", userLanIDParameter, emailParameter)
}
與得到這個在我的存儲過程的成功捆綁任何援助將不勝感激。謝謝!
更新
我已經試過這是一個解決方案:http://sanganakauthority.blogspot.nl/2013/07/the-function-import-cannot-be-executed.html,但是這是行不通的。
我刪除的功能重新導入它,如下圖所示:
但是當我這樣做,我得到這個錯誤。修復它雖然通過運行。 通過運行模型的生成數據庫修改對應關係後
但是從模型生成數據庫,我失去了存儲從採購參考,如下圖所示:
任何想法我做錯了,或者我需要做些什麼來實現這個目標?
我已經試過了,但它在這種情況下不工作 – LifeOf0sAnd1s