# Wednesday, December 19, 2012

At BUILD, during this session by Entity Framework Program Manager Rowan Miller, Entity Framework 6 beta was announced and made publicly available.  You can get the Entity Framework 6 beta bits via NuGet.  Currently they are only available via the Package Manager Console, more info can be found on the EF NuGet page

Entity Framework 6 is the first new version of EF since the announcement earlier this year that the product would be Open Sourced.  This means that not only is the source available but the builds of EF6 beta are available as soon as the code is checked in.  Entity Framework is hosted on CodePlex.

The EF 6 roadmap defines in detail what is currently in the works and what is still on the board as far as features and improvements for EF 6.  In this post I want to focus on one new addition to Entity Framework that I find very compelling.

One of the great features introduced in .NET 4.5 was the task-based asynchronous functionality using the async and await keywords.  Now with EF 6 comes support for asynchronous querying and saving using the same async and await coding convention.  Let’s first look at asynchronous querying.

The following asynchronous extension methods have been implemented for querying your data context and as you’d expect they are the asynchronous versions of their synchronous namesakes:

  • AllAsync
  • AnyAsync
  • AverageAsync
  • ContainsAsync
  • CountAsync
  • FindAsync
  • FirstAsync
  • FirstOrDefaultAsync
  • LoadAsync
  • LongCountAsync
  • MaxAsync
  • MinAsync
  • SingleAsync
  • SingleOrDefaultAsync
  • SumAsync
  • ToArrayAsync
  • ToDictionaryAsync
  • ToListAsync

In the code snippet below you can see an example of using the ForEachAsync method to asynchronously loop through all the manufacturers in my data context and print them to the console.

private static async Task PrintAllManufacturers() {
    using (DataContext context = new DataContext()) {
        await context.Manufacturers.ForEachAsync(m => Console.WriteLine("{0} : {1}", m.Name, m.Country));

Another piece of Entity Framework functionality that the asynchronous goodness has been added too is saving. Below is an example of adding a manufacturer and asynchronously saving the changes.

private static async Task AddManufacturer(string name, string country) {
    using (DataContext context = new DataContext()) {
        context.Manufacturers.Add(new Manufacturer {Name = name, Country = country});
        await context.SaveChangesAsync();

Using the asynchronous pattern is a great way to provide a more responsive user experience and now loading data asynchronously with Entity Framework has become much easier.

posted on Wednesday, December 19, 2012 11:08:48 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
# Saturday, September 01, 2012

This week I had the pleasure of speaking at devLINK.  I did 5 sessions over the 3 day conference and had a blast networking with the other speakers and attendees.  Kudos to the devLINK staff on a job well done.

Here are the 5 sessions I did at devLINK 2012 and links to the associated slides and demos.

posted on Saturday, September 01, 2012 6:45:00 PM (Central Daylight Time, UTC-05:00)  #    Comments [0]
# Thursday, August 23, 2012

As most of you know I am very active in the development community and one piece of that is my involvement with the Midwest Give Camp organization. The Midwest Give Camp organization is a small group of dedicated community leaders that plan and carry out yearly Give Camps in the Midwest. This year I had the honor of organizing/leading the Midwest Give Camp. The event was held the weekend leading in to That Conference at the same venue. I wanted to share details on the charity that we worked with and what the Give Campers were able to provide for them.

For the 2012 installment of the Midwest Give Camp we worked with the charity Katharine’s Wish. Katharine’s Wish was founded by Katharine Rhoten of Eau Claire, WI. Katharine’s father Doug is also an active member of the developer community who runs the Chippewa Valley .NET User Group. Doug also happens to be a personal friend of mind.

While on the family’s first trip to Disney World in 2008 Katharine became seriously ill and was rushed to the hospital. The Rhoten family spent 3 long days in the hospital watching Katharine undergo numerous tests, most involving painful prods and pokes. Through all of those procedures Doug and his wife Kristin where amazed at the positive attitude Katharine was able to keep. This was due, in large part, to a small gesture of the hospital staff. Prior to any painful procedure, the hospital staff gave Katharine a small stuffed animal. This always put a smile on Katharine’s face and let her know that it may hurt for a bit but in the end everything was going to be alright. To get an idea of the number of procedures Katharine was subjected to during her stay at the hospital…Doug had to ship 2 boxes of stuffed animals back to WI J

The experience provided two major life-changing events for Katharine. The first was that she was diagnosed with Type I Diabetes and the second that she vowed to “pay it forward” by doing everything she could do to make sure that children in the hospital have the same positive experience she had. Upon returning home Katharine got to work on making this happen by using her allowance, birthday money, and funds from a lucrative lemonade stand to purchase stuffed animals to donate to local hospitals that she donates each year, on the anniversary of her diagnosis, to local hospitals.

Katharine’s Wish has grown to now include multiple drop off locations where the community can drop off stuffed animals and books to be donated. In the five years since her diagnosis, Katharine, with the help of her younger brother Spencer, has donated thousands of stuffed animals and books to the hospitals in her community.

It was an honor to be able to use my skills, along with the skills of 12 other talented geeks, to provide Katharine with a platform to grow her cause. The result of our work is the official Katharine’s Wish web site. The site was coded in MVC 4/HTML5/Kendo UI on the front end and EF Code First/SQL on the back end.

I ask that you please check out http://www.KatharinesWish.org to learn more about this awesome girl and please consider donating to her cause.

posted on Thursday, August 23, 2012 4:22:00 PM (Central Daylight Time, UTC-05:00)  #    Comments [5]
# Wednesday, August 01, 2012

Last month I had the awesome opportunity to be part of the aspConf virtual conference.  aspConf evolved from the very popular mvcConf, but instead of being focused solely on ASP.NET MVC aspConf is focused on the entire ASP.NET stack of goodness.  The great thing about aspConf is that it is a virtual conference allowing for a much broader audience.

I presented two sessions at aspConf:

  1. Test Driving ASP.NET MVC - (slides and code)
  2. Kendo UI - Lighten Your Load by Adding a Sword(slides and code)

The aspConf staff also put in the immense effort of editing every session and making them available on Channel 9 for everyone to watch.

If you missed aspConf this year, well you can always watch it on Channel 9, but also make sure you follow them on Twitter and keep on eye on the aspConf site so you don’t miss next year’s event!

posted on Wednesday, August 01, 2012 6:28:16 AM (Central Daylight Time, UTC-05:00)  #    Comments [3]
# Friday, June 29, 2012

A great new feature in ASP.NET MVC is the ability to bundle scripts and CSS files and register them as a group.  More detail on this functionality can be found here.  Because by default all the scripts and CSS classes in a new MVC 4 project are registered using bundles I felt a little dirty in my previous posts referencing my Kendo UI scripts and CSS files each individually.  I rectified that.

So I started the rectification process by adding entries to the BundleConfig.cs.  In this file is where you create and configure your bundles.  Out of the box there are a number of bundles configured so all I needed to was follow the same conventions when creating my bundles. 

bundles.Add(new ScriptBundle("~/bundles/kendojs").Include(
bundles.Add(new StyleBundle("~/Content/kendocss").Include(

Obviously I took the least amount of scripts I needed to get my contrived sample created, but you can add whatever scripts you need.

After creating the bundles I need to register or “Render” them as the method is called.  Have to admit I am not a fan of “Render” as the method name.  In the past “Render” has always had a visual connotation.  The registering of the bundles for this example is taking place in the _layout.cs, but you could do the same thing directly in your ASP.NET MVC View.

@Styles.Render([...other CSS bundles], "~/Content/kendocss")
@Scripts.Render([...other Script bundles],"~/bundles/kendojs")

And that’s it.  Now I have my Kendo UI scripts and CSS files registered/referenced/rendered using the new bundling features of ASP.NET MVC

Code is available on GitHub.

posted on Friday, June 29, 2012 3:38:27 PM (Central Daylight Time, UTC-05:00)  #    Comments [4]