触发器引发的entityframework异常
触发器可能会导致ef无法正常工作,产生下面的错误:
此时修改触发器为:
CREATE TRIGGER [dbo].[CreateTradeOrdNo]
ON [dbo].[trade_Order]
for INSERT
--, update,delete
AS
BEGIN
select * from inserted--加上这一句
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: identity
Description: 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: identity
Source 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