Hello,
NOTE: Tracing this was done via the Reflector generate PDB function so cannot vouch 100% for accuracy but have I have matched it up with the source in codeplex which makes sense so guessing it's right.
I am throwing an UpdateException [1] in EntityFramework.SqlServer/SqlGen/DmlSqlGenerator.cs - public override void Visit(DbScanExpression expression).
Unfortunately I have been scratching my head as to the issue is as the exception gets hidden due to a null reference exception being thrown in EntityFramework/Internal/InternalContext.cs due to UpdateException.StateEntries being null.
Looking at UpdateException.cs only one of the constructors instantiates the StateEntries collection and is not the one that is used for generation of the exception that is being thrown.
Cheers
Bart
[1]
System.Data.Entity.Core.UpdateException occurred
_HResult=-2146232032
_message=Unable to update the EntitySet 'tblMyTable' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
HResult=-2146232032
IsTransient=false
Message=Unable to update the EntitySet 'tblMyTable' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
Source=EntityFramework.SqlServer
StackTrace:
at System.Data.Entity.SqlServer.SqlGen.DmlSqlGenerator.ExpressionTranslator.Visit(DbScanExpression expression)
InnerException:
Comments: Note for triage: I was able to repro something similar with a very simple project. When an UpdateException should be thrown with no entries, we throw ArgumentNullException from WrapUpdateException. Looks like something we should fix for RTM. Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: source at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func2 predicate) at System.Data.Entity.Internal.InternalContext.WrapUpdateException(UpdateException updateException) at System.Data.Entity.Internal.InternalContext.SaveChanges() at System.Data.Entity.Internal.LazyInternalContext.SaveChanges() at System.Data.Entity.DbContext.SaveChanges() at ConsoleApplication17.Program.Main(String[] args) in c:\X\Program.cs:line 17
NOTE: Tracing this was done via the Reflector generate PDB function so cannot vouch 100% for accuracy but have I have matched it up with the source in codeplex which makes sense so guessing it's right.
I am throwing an UpdateException [1] in EntityFramework.SqlServer/SqlGen/DmlSqlGenerator.cs - public override void Visit(DbScanExpression expression).
Unfortunately I have been scratching my head as to the issue is as the exception gets hidden due to a null reference exception being thrown in EntityFramework/Internal/InternalContext.cs due to UpdateException.StateEntries being null.
Looking at UpdateException.cs only one of the constructors instantiates the StateEntries collection and is not the one that is used for generation of the exception that is being thrown.
Cheers
Bart
[1]
System.Data.Entity.Core.UpdateException occurred
_HResult=-2146232032
_message=Unable to update the EntitySet 'tblMyTable' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
HResult=-2146232032
IsTransient=false
Message=Unable to update the EntitySet 'tblMyTable' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
Source=EntityFramework.SqlServer
StackTrace:
at System.Data.Entity.SqlServer.SqlGen.DmlSqlGenerator.ExpressionTranslator.Visit(DbScanExpression expression)
InnerException:
Comments: Note for triage: I was able to repro something similar with a very simple project. When an UpdateException should be thrown with no entries, we throw ArgumentNullException from WrapUpdateException. Looks like something we should fix for RTM. Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: source at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func2 predicate) at System.Data.Entity.Internal.InternalContext.WrapUpdateException(UpdateException updateException) at System.Data.Entity.Internal.InternalContext.SaveChanges() at System.Data.Entity.Internal.LazyInternalContext.SaveChanges() at System.Data.Entity.DbContext.SaveChanges() at ConsoleApplication17.Program.Main(String[] args) in c:\X\Program.cs:line 17