Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating blob properties with Entity Framework 4?

I am creating an EF4 model-first application with a WPF UI. One of the controls on my UI is a RichTextDocument, which outputs a WPF FlowDocument. I can either serialize the FlowDocument to a byte array, or extract its XAML markup as a string. I would prefer to use binary serialization, if I can. Here are my questions:

  • If I serialize to a byte array, how do I specify an entity property as a byte array in the EDM Designer?

  • If I extract a XAML markup string, can I specify that the EDM Designer create the corresponding database column as a nvarchar(max) column?

As to the second question, I assume I could always manually edit the MyModel.edmx.sql file to change the data type from nvarchar(4000) to nvarchar(max) before executing it, but I would like to know if it can be done in the Designer.

Thanks for your help.

like image 687
David Veeneman Avatar asked Mar 18 '10 20:03

David Veeneman


1 Answers

Finally got back to this one. Turns out that if it had been any more obvious, I'd have tripped over it. EDM has a Binary type that creates a property of type byte[] on an entity class. While the types in the EDM Designer generally match CLR type names, that's not true in all cases, as this issue shows.

like image 117
David Veeneman Avatar answered Sep 28 '22 08:09

David Veeneman