An Open Letter to the Microsoft Data Teams About Enums
Dear Microsoft Data Teams,
First off, I just want to say that I think the work you guys have done over the last 6 years has been awesome. Seriously. It has never been easier to get information into an out of a database, and throw it over a service. And the work with EF 5.0 on .NET 4.5 has brought with it some outstanding work in performance, usability, and especially support for Enums.
But this improvement has come at a price. Because OData does not officially support the concept of a first-class Enum type, if you are using any of the methods of leveraging OData (WCF Data Services or the new WebApi OData support, specifically) your code will break without any kind of warning. Why? Because "Enum" is itself a new enumeration entry in the EdmTypeKind, and there is not a build of WCF Data Services explicitly for .NET 4.5 that filters this type out while initializing entities. In WCF Data Services, the metadata startup code only checks for one value in the EdmTypeKind enumeration, and assumes all others will work on the "Else" codepath... which is not true for Enums.
So if you update a project running EF5 + WCF Data Services to .NET 4.5, you will be greeted with a low-level failure on your services that cannot be overridden without hundreds of lines of reflection code (believe me, I've tried).
It is amazing to me that you guys at Microsoft can even get away with this kind of breakage without repercussions. The downloads for EF5 or WCF Data Services do not explicitly state that you cannot add Enums to your model if you want to still be able to run WCF Data Services. I guess you guys just assume that it won't be an issue, because Enums are new and people won't try to build services that support them.
If you assumed that, you were wrong.
But it doesn't have to be this way. I've asked those among you several times why there is no support, and the answer I keep getting back is somewhere along … Continue reading...
Pre-generating Views to Improve Performance in EF5
The other day, the EF Team posted guidance on how to improve performance for Entity Framework 5.0. Their very first recommendation was to pre-generate the Views that EF uses to run its queries. Typically these views are automatically generated the first time the application is executed, but this can dramatically increase the execution time on the first query.
Their solution was to pre-generate the code using EdmGen.exe, and in 2008 the team provided a T4 template to automate that process for Database First and Model First scenarios. However, the latest guidance provided incomplete information on how to update that template to run in Visual Studio 2011. Since I'm getting ready to release several other tools for EF5, I thought it would be a good time to learn the ins and outs of publishing a template to the Visual Studio Gallery.
Using the latest DbContext genrators Microsoft put out as a guide, I was able to figure out how to have the template show up as a Code Generation Item in the Entity Designer. Just right-click anywhere in the designer, select "Add Code Generation Item", and then select "EF 5.x Views Generator". The views will automatically be added to your project, all you need to do is hit "Compile", and watch your first query execute just as quickly as all the others.
Though I will not be providing any "official" support, if you have any issues, please let me know. Oh, and you can download the template here, or by searching for "views generation" in the Visual Studio 11 Extension Manager. Continue reading...
Updating Your Windows Phone to 8107
UPDATE: If you have the Trophy, you can use these instructions to upgrade to 7740, but not 8107. There is apparently a driver mismatch or something that is causing the phone dialer to crash.
UPDATE 2: So apparently, this update has an ENGLISH language pack as well. Not sure why. On the Verizon HTC Trophy, you need both the English and Spanish language packs. Check your phone before you update. Additional instructions are below.
UPDATE 3: I just received the "HTC Update for Windows Phone" from Verizon with this update already installed, so it appears that if you follow these directions, you should be able to update safely (at least with the Verizon HTC Trophy). I have also added additional language packs (see #7, thanks Plaffo.com!)
So I'm pretty fed up with cell carriers (and now Microsoft) and their update nonsense. I have the HTC Trophy on Verizon, and I doubt they will ever pick up any new interim updates to the phone. In fact, if they don't announce a new Windows Phone at CES next week, I am finally jumping ship to AT&T.
So instead of waiting for an update that will probably never come, I decided to update my phone myself. Fortunately, Italy's premier Windows Phone community "Plaffo" has instructions on how to do so. Here is the English version of the post, but I'll summarize the instructions below to keep it simple. FOLLOW THEM AT YOUR OWN RISK.
Make sure your phone is charged to at least 50%. Plug your phone into your computer, and then close Zune.
On your phone, go to Settings | Region + Language | Display Language and make note of the available languages.
Download a tool from xb0xm0d (WP7 CAB Update Sender) that allows you to connect to the phone, back it up, and pass CAB files as updates.
Extract the tool to any folder.
Download the 7740 update CAB file to the same place you extracted the CAB Update Sender (this is from an official Microsoft download server). … Continue reading...
Making Your Code Pretty on Orchard with SyntaxHighlighter
This site is powered by Orchard CMS, and I'm a huge fan of the design. I'm not the biggest fan of the documentation tho, and many of the plugins suffer from the same lack of documentation. While I was working on my last post, I needed a way to be able to post code. I really like the version of SyntaxHighlighter that used to have the "copy to clipboard | raw view" toolbar in the corner, but apparently that used Flash, and the new version does not.
At any rate, I wanted to write about how to how to configure SyntaxHighlighter with Orchard, as the documentation isn't exactly clear, and the built-in editor doesn't like it very much.
Step 1: In the Admin console, go to "Modules | Gallery", search for "SyntaxHighlighter", and install and activate "SyntaxHighlighter for Orchard".
Step 2: Go back to the Modules Gallery, search for "CKEditor", and install it.
Step 3: Go to Modules, and under the "Input Editor" section, disable "TinyMCE".
Now, when you go to post, wrap your code in <pre class="brush: csharp">Your code here</pre>, and you'll be good to go. Continue reading...
Simplify your WPF Converters with the ConvertibleMarkupExtension
You can't get away with coding in XAML without using IValueConverters. If by some miracle you've figured out how, then please, do share :). In the meantime, there is a way to keep you from having to declare each converter you use as a named resource, through MarkupExtensions. Some great examples of this technique can be found here and here. Continue reading...
Welcome to the new site!
It has been far too long since I've had a personal blog, so it's time to fire this sucker up again. I've been working on a lot of WP7 apps and different NuGet projects lately, and each of those projects needed a home to talk about them. So now they live here. The site is pretty self-explanatory, so there is no need to go through each section. So have a look around, and please feel free to leave me feedback. Thanks! Continue reading...