Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Entity Framework CF store 'object type' values?

it's a question.

I need to store props for my objects. And I do not know - what kind of prop it is - it's data driven. I use 'object type' for 'value' of prop, but... Will EF work with object type?

Object is never complex type - it's Boolean,String,Int and Guid.

Until EF steps in the game - all was OK.

Thanks.

like image 781
Monochromie Avatar asked Aug 03 '12 19:08

Monochromie


1 Answers

No. EF doesn't support this because it would require "dynamic" column type in the database. Database can support such scenario - for example SQL server offers sql_variant. Unfortunately EF cannot map these columns. Here is workaround for using variant column in read only scenarios. The workaround uses DefiningQuery in EDMX. In theory you should be able to map modification commands as well to be able to use it for saving changes. It is not possible to use it in code first - code first offers only basic mapping.

like image 193
Ladislav Mrnka Avatar answered Oct 26 '22 20:10

Ladislav Mrnka