觸發器引發的entityframework異常

來源:互聯網
上載者:User
 觸發器可能會導致ef無法正常工作,產生下面的錯誤:

此時修改觸發器為:

CREATE TRIGGER [dbo].[CreateTradeOrdNo] 
   ON  [dbo].[trade_Order]
   for INSERT
--, update,delete
AS 
BEGIN

select * from inserted--加上這一句

END 

 

The member with identity '' does not exist in the member collection.

Parameter name: identityDescription: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: The member with identity '' does not exist in the member collection.Parameter name: identitySource Error: Line 71:         //MacBook Pro(13-inch)Line 72:         le.AddTotrade_Order(to);Line 73:         le.SaveChanges();Line 74:         price = to.price;Line 75:         orderId = to.id;Source File: e:\laptop\laptop\WebSite\trad-in\index.aspx.cs    Line: 73 Stack Trace: [ArgumentException: The member with identity '' does not exist in the member collection.Parameter name: identity]   System.Data.Metadata.Edm.MemberCollection.get_Item(String identity) +3573762   System.Data.Metadata.Edm.ReadOnlyMetadataCollection`1.get_Item(String identity) +136   System.Data.Metadata.Edm.FilteredReadOnlyMetadataCollection`2.get_Item(String identity) +22   System.Data.Metadata.Edm.FilteredReadOnlyMetadataCollection`2.System.Data.Metadata.Edm.IBaseList<TBase>.get_Item(String identity) +15   System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues) +312   System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) +281[UpdateException: An error occurred while updating the entries. See the InnerException for details.]   System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) +491   System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache) +117   System.Data.Objects.ObjectContext.SaveChanges(Boolean acceptChangesDuringSave) +453   System.Data.Objects.ObjectContext.SaveChanges() +9   trad_in_index.saveBaseInfo() in e:\laptop\laptop\WebSite\trad-in\index.aspx.cs:73   trad_in_index.btnSubmit_Click(Object sender, EventArgs e) in e:\laptop\laptop\WebSite\trad-in\index.aspx.cs:91   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.