1
votes

In core 1.1 I used the TypeName = "sql_variant" attribute on the property and it worked.

[Column("tx_value", TypeName = "sql_variant")]
public string Value { get; set; }

I have migrated to core 2.1, started to return the error (The property 'EnterpriseDetails.Value' could not be mapped, because it is of type 'string' which is not a supported primitive type or a valid entity type. property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'). How to solve this?

1

1 Answers

0
votes

Your syntax looks fine. The issue is that SQL_VARIANT does not map directly to a 'string' primitive type. Since the data that can be populated in SQL_VARIANT is highly variable, you will need to use the object type.

[Column("tx_value", TypeName = "sql_variant")]
public object Value { get; set; }

More information on SQL_VARIANT from MS Docs.