I am having a difficult time resolving a silly mapping problem. Basically what is going on is that I have a field in a sql db table that is a varbinary for the purposes of security (encryption and decryption). All that stuff is all well and good but it seems as though the edmx sees the field in that table as a string which I thought it should see it as given that the data is just a binary string. This is the error message I get.
Schema specified is not valid. Errors:
ReadModel.Model.msl(836,12): error 2019: Member Mapping specified is not valid. The type
'Edm.String [Nullable=True,DefaultValue=,MaxLength=256,Unicode=,FixedLength=False]' of
member 'field-in-question' in type 'Lib.ReadModel.TableName' is not compatable with
'SqlServer.varbinary' [Nullable=True,DefaultValue=,MaxLength=256,FixedLength=False]'
of member 'field-in-question' in type 'Model.Store.TableName'.
Has anyone had an issue like this? Maybe there is something I am overlooking? Maybe be able to point me in the right direction? I am having an issue on finding information to resolve the issue and am at a loss.
Ok, for those that ever have an issue like this it turns out that it seems to be best solved by deleting and re-adding the entity again in the edmx. It's a silly thing in my opinion, but it works. Bah.
EF (or a user change at some point) had changed(?) the edmx's Model
Entity
for that property to be a Edm.String[Nullable=True,DefaultValue=,MaxLength=256,Unicode=,FixedLength=False]
instead of a varbinary
. The error reads local entity first followed by the database definition
Alternate Fix; Just As Viable
Yes your fix did resolve the problem...
But the problem could have also been properly resolved by setting the correct value in the edmx such as ->
Model Browser
window, then by opening up the tree.Model
->Entity Types
then finding the target entity, and opening it up then selecting its Properties
Type
to a proper value.The example above shows DateTime
but in your case it would have shown String
, which the error dutifully reported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With