Closed somjetsomjet closed 7 years ago
Hi somjet,
Could you post the full code which demonstrates the issue?
please see full code https://github.com/somjetsomjet/test-ef-trigger-sample
I see that Details1Error
is of type IEnumerable<T>
, which won't be seen by Entity Framework as a mappable type. In other words, it won't work unless you use ICollection<T>
.
Once you make that change, you'll see that the exception changes to one telling you that collection types are not supported by the "Original" values look-up.
The other thing I noticed is that you're using the instance constructor (public Order()
) instead of the static constructor to set up your triggers. Your code will add the trigger every time you make an Order
object.
I change "IEnumerable" to "virtual ICollection" and change "public Order()" to "static Order()" but can't fix error, How to use "Original"?
have error The type initializer for 'EntityFramework.TypedOriginalValues.OriginalValuesWrapper`1' threw an exception.
Could not load type 'Order_45A70B3DD01BC4D0D28B869261AAC8E5FC7C23F053AB4D5FBD5DD88D46F1906DOriginalValuesWrapper' from assembly 'Order_45A70B3DD01BC4D0D28B869261AAC8E5FC7C23F053AB4D5FBD5DD88D46F1906D__OriginalValuesWrapperAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because the parent type is sealed.":"Order_45A70B3DD01BC4D0D28B869261AAC8E5FC7C23F053AB4D5FBD5DD88D46F1906DOriginalValuesWrapper
Collections are not supported by .Original
, but this cryptic exception is a bug and I will look into it.
when call
have error => Member 'OriginalValue' cannot be called for property 'Details' on entity of type 'Order' because the property is not part of the Entity Data Model.