Silverlight: Lighting up the client

At PDC last week, Scott Guthrie showed some of the great apps developers have already built for Windows Phone 7 using Silverlight, as well as the rich set of development tools we have just delivered for building applications with it.  if you missed PDC, you can view the keynote and other sessions at (in Silverlight of course!).

Following PDC there have been questions surrounding Silverlight’s future, and I wanted to apologize for our role in causing some confusion around that. Earlier today, Bob Muglia posted some clarifications about this topic and the very important strategic role Silverlight has going forward.

Silverlight enables developers to build fantastic media experiences and business applications for the client, and applications for phone and embedded devices.  Organizations are already using Silverlight 4 as an incredibly powerful enterprise business application platform (complete with powerful data-binding support, networking, WCF, printing, MVVM pattern separation, and more), which together with the tooling improvements we’ve made in Visual Studio and Expression Blend, enables developers to build great enterprise applications with high productivity and results.

I’m very proud of the work we’ve done in four versions of Silverlight and am very excited about the work we’re doing for the next version and we have plenty more to do.

Silverlight: Lighting up the client

EF Code First and Data Scaffolding with the ASP.NET MVC 3 Tools Update

Earlier this week I blogged about the new ASP.NET MVC 3 Tools Update that we shipped last month. 

In today’s blog post I’m going to go into more detail about two of the cool new features it brings:

  1. Built-in support for EF 4.1 (which includes the new EF “code-first” support)
  2. Built-in data scaffolding support within Visual Studio (which enables you to rapidly create data-driven sites)

These two features provide a really sweet, and extremely powerful, way to work with data and build data-driven web applications.

Scenario We’ll Build

To help illustrate how to use the above features, we’ll walkthrough building a simple data-drive site.  It will support listing products:

As well as creating/editing new products (and categories):

We can now build this entire application (and create the database that backs it) with ASP.NET MVC 3 in only a minute or two.

Step 1: create new Project

We’ll begin by creating a new ASP.NET MVC 3 project (using the File->new Project menu command).  We’ll use the “Internet Project” template – which will provide us with a default starter template for our application. 

When you look at the newly created project within the Solution Explorer, you’ll see that the ASP.NET MVC 3 Tools update adds a new assembly – EntityFramework – to our ASP.NET MVC 3 projects:

The EntityFramework assembly implements Entity Framework 4.1 – which we also released last month.  EF 4.1 brings with it a bunch of great data API improvements to .NET – including the new “code first” option.  EF Code first provides a really elegant and clean way to work with data, and enables you to do so without requiring a designer or XML mapping file.  you can now easily take advantage of this by default with all new ASP.NET MVC 3 projects.

We’ll be using the EF Code first approach to implement our data access for this application.

Step 2: Implement Model Classes

Our first step will be to create two classes – Product and Category – that we’ll use to define the “model” of our application.  We’ll implement these as standard “plain old C# objects” within the Models folder of our project using the code below:

Notice how the above classes are just standard classes with .NET data-types.  they do not need to derive from any base class, nor implement any interfaces. 

In addition to standard scalar properties, each class has an “association” property.  for example, the “Product” class has a “Category” property that enables a developer to get access to the Category it belongs to.  Likewise the “Category” class has a “Products” property that enables a developer to retrieve the Products that are within that particular Category.  EF Code first can handle automatically managing these associations (using the Primary Key/Foreign Key values), and can lazy load the appropriate data on-demand.

Step 3: Implement a StoreContext Class using EF Code First

Now that we’ve defined our two model classes, our next step will be to implement a “DbContext” class using EF code first that will map the model classes to tables in a database.  We’ll implement this using the code below:

The “StoreContext” class above is the DbContext class we are using to map our Product and Category classes to/from a database.  It derives from the DbContext base class provided by EF Code first, and exposes two properties that correspond to tables within our database.  for this sample we are using the default “convention over configuration” based mapping rules to define how the classes should map to/from the database.  This means that the Products property will map to a Products table, and the Categories property will map to a Categories table.  In later blog posts I’ll talk about how you can optionally override this and perform custom mappings.

You can add the above class anywhere within your solution.  for example, you could add it within the Models folder of your project – or within a separate class library project if you prefer to keep your data code separate.  You’ll want to add a “using” statement to the System.Data.Entity namespace at the top of the class file (in order to reference the DbContext and DbSet<T> classes).

After you’ve saved the above class files, compile the project – you’ll want to have built it before the next step.

Step 4: Scaffold a Categories Controller

We have everything we need to model our data and save/retrieve it from a database.  Now let’s create an ASP.NET MVC Controller class that will implement the support necessary to display our Category data and enable creating/editing/deleting Category objects.  Prior to last month’s ASP.NET MVC 3 Tools Update, you would have had to manually write a Controller class to do this (and implement all of the EF data access code yourself).  the ASP.NET MVC 3 Tools Update now includes built-in “scaffolding” support that can help do this for you automatically.

To scaffold a new Categories controller class, we’ll right-click on the “/Controllers” folder of our project and choose the Add->Controller context menu:

Selecting Add->Controller will bring up the “Add Controller” dialog.  We’ll name the controller class we want to create “CategoriesController”.  Starting with last month’s ASP.NET MVC 3 Tools Update, the “Add Controller” dialog also now supports a new “Scaffolding options” section – which enables you to choose to “scaffold” the new controller using a variety of built-in templates:

We’ll choose the “Controller with read/write actions and views, using Entity Framework” template – which will create a Controller class that has all of the EF code necessary to create, update, list and delete model objects.

After selecting this template, we can choose the model class we want our Controller to implement CRUD support for – in this case the “Category” class.  We can also select the EF DbContext/ObjectContext class that we want to use to access the database – in this case the “StoreContext” class we defined earlier:

When we click the “Add” button, Visual Studio will automatically create a CategoriesController class for us – with appropriate create, Edit, Details, Delete and Index action methods inside it – as well associated view templates for each of the actions:

If you open the CategoriesController.cs class you’ll find that the action methods within it implement the EF data access code necessary for CRUD support:

And now we have all of the code we need to implement data listing/editing for Categories within our database

Step 5: Configuring our Database Location

The last step we’ll do before running our application is to point our application at the database we want to use.  EF code first allows you to use an existing database you already have defined, or alternatively you can point it at a database that doesn’t yet exist – in which case it will automatically create it for you using the model classes you’ve defined.

No Connection-String

By default, you actually don’t need to configure a connection-string to point at a database.  If you don’t specify one, EF Code-First will by default create a new SQL Express database whose name matches your DbContext class name (for example: above it would create a ScaffoldingDemo.Models.StoreContext database within your local .SQLExpress database instance). 

Explicitly specifying a Connection-String

You can alternatively explicitly specify where you want your database to live by adding a connection-string to your application’s web.config file.  You’ll want the name of the connection-string to match the DbContext class name.  for example – in our application above our DbContext class was named “StoreContext”, and so by default EF will look for a connection-string with the same name to determine the database location.

Below is the entry we’d add to our web.config file if we wanted to use an embedded SQL CE database named “Store.sdf” within our application’s App_data folder:

              <add name="StoreContext"
                         connectionString="Data Source=|DataDirectory|Store.sdf"
                         providerName="System.Data.SqlServerCe.4.0" />


You can learn more about SQL CE – and the new VS 2010 SP1 tooling support for it – from my previous blog post about it.

Step 6: Run the Application

Ok – let’s now run the application and navigate to the /Categories URL.  This will execute our CategoriesController’s Index() method – which will list all categories in our database.  Currently we don’t have any:

Let’s click the “Create New” link to create a new category – this will navigate to the /Categories/Create URL, which provides us with a form to create a new category:

Clicking the “Create” button will post the form to our CategoriesController and add a new Category to our database.  We can repeat this a few times to add several different categories:

The cool thing is that we didn’t have to write any Controller or View code to enable this – the scaffolding support automatically generated the code we needed to enable this.  This provides a really easy way to get started.  We can then go in and tweak it as necessary to customize the functionality further.

Step 7: looking at the database

We configured our application to use a connection-string that pointed to a SQL CE database that (at the time) didn’t exist.  when we ran our application, EF 4.1 detected that the database didn’t exist and automatically created it for us – based on the Product and Category classes we defined earlier. 

To see the database, click the “Show All Files” icon at the top of Visual Studio’s “Solution Explorer” and add the “Store.sdf” database that was automatically created by EF to your project:

You can then double-click the database to open it up in the Server Explorer – and expand the tables within it to see the schema that was created:

Notice above how EF Code first automatically created the appropriate database schema based on the Category and Product classes we created earlier.  It also automatically setup Primary Key/Foreign-Key relationships between the two tables based on the association properties specified in the classes.

Step 8: Scaffolding a Products Controller

We’ve created a CategoriesController class to manage listing and editing Categories.  Let’s now create a ProductsController class to manage listing and editing Products.

Just like before, we’ll right-click on the Controllers folder in our project and choose the Add->Controller context menu.  We’ll name the Controller class we want to create “ProductsController” and indicate that we want to scaffold using the EF template with a Product model class:

Clicking the “Add” button will scaffold a ProductsController class for us, with appropriate action methods for CRUD scenarios, and create the associated view templates that go with them:

We can then run our project again and navigate to the /Products URL within it:

Let’s click the “Create New” link to create a new Product:

One cool thing to notice is that the “Category” is a drop-down of valid Categories (and not just a textbox with a foreign-key integer value):

The scaffolding support within Visual Studio was smart enough to detect that Category was an association, and scaffold EF code that populates the drop-down with valid Categories.

After entering several products our /Products URL will display the data like below:

Notice again how Category is displayed using the friendly name – and not just the foreign-key value.

Learning More

The above walkthrough provided a quick look at the new EF code-first and data scaffolding support built-into the ASP.NET MVC 3 Tools Update, and how you can use them to easily and quickly jumpstart application development.  EF Code first enables you to write incredibly clean data access code.  the data scaffolding support enables you to rapidly create data UI – and then allows you to go in and easily tweak/customize it further.

In addition to working with EF Code-First, you can also use the data scaffolding support against standard EF ObjectContext objects (built using either the database-first or model-first approach and the EF WYSIWYG designer).


You can learn more about the new ASP.NET MVC 3 Scaffolding Support from Steve Sanderson’s excellent talk about it at MIX:

In his talk Steve also covers how you can use the scaffolding support from the command-line (using NuGet) as well as how you can download and use additional scaffolding templates (for example: ones that can automatically implement a repository pattern, etc).  Also make sure you bookmark Steve’s excellent blog series about scaffolding (and its extensibility) here:

EF Code First

I’ll be doing more blog posts about EF Code first in the future.  Below are links to some tutorials I’ve written in the past about it:

Note: the above tutorials were written against the CTP4 release of EF Code first (and so some APIs are a little different) – but the concepts and scenarios outlined in them are the same as with the final release.


If you want to learn more about ASP.NET MVC 3, I highly recommend Scott Hanselman’s excellent video presentations at the Dutch DevDays and at MIX:

Also check out all of the new content and videos on the web-site:


The new ASP.NET MVC 3 Tooling Update is full of goodness.  If you haven’t already downloaded and installed it I highly recommend you do so.  Stay tuned for even more blog posts about it!

P.S. I am also now using Twitter for quick updates and to share links. Follow me at:

EF Code First and Data Scaffolding with the ASP.NET MVC 3 Tools Update

Internet Explorer 9 Now Available in 93 Languages

Internet Explorer 9 is now available in more local languages than any other browser on Windows. Today, we released support for IE9 in 53 additional languages, making IE9 available in a total of 93 languages:

Please visit the Worldwide downloads page to download IE9 in a language of your choice. Here’s the complete list of languages Internet Explorer 9 is available in, starting with the originally released 40 and followed by the 53 new languages in blue:

Arabic Lithuanian Bengali (India) Malayalam Bulgarian Norwegian (Bokmål) Bosnian (Cyrillic) Maltese Catalan Polish Bosnian (Latin) Maori Chinese (Hong Kong SAR) Portuguese (Brazilian) Filipino Marathi Chinese (Simplified) Portuguese (Portugal) Galician Nepali Chinese (Traditional) Romanian Georgian Norwegian (Nynorsk) Croatian Russian Gujarati Oriya Czech Serbian (Latin) Hausa Persian Danish Slovak Icelandic Punjabi Dutch Slovenian Igbo Quechua English (US) Spanish (Spain) Inuktitut Serbian (Cyrillic) Estonian Swedish Irish Sesotho Finnish Thai isiXhosa Setswana French Turkish isiZulu Sinhala German Ukrainian Kannada Tamil Greek Vietnamese Kazakh Tatar Hebrew Albanian Khmer Telugu Hindi (India) Afrikaans Kiswahili Urdu Hungarian Amharic Konkani Uzbek Indonesian Armenian Kyrgyz Welsh Italian Assamese Luxembourgish Yoruba Japanese* Azerbaijani Macedonian Korean Basque Malay (Brunei Darussalam) Latvian Bangla (Bangladesh) Malay (Malaysia)

* Japanese language support released on April 25, 2011

a browser in the language of the user’s choice is an important part of delivering the best experience of the Web on Windows. With IE9, our goal was to deliver more languages faster. With today’s release, IE9 is available in all languages that Windows Vista is available in and in 93 of 96 languages Windows 7 is available in.

Installing Internet Explorer 9 in a language of your choice

you can install localized versions of IE9 in a language that matches your version of Windows or choose to install the English version of IE9, which works with all versions of Windows Vista and Windows 7.

Users on multi-lingual versions of Windows or users who have already installed IE9 English or one of the previously supported languages can install a language pack to experience IE9 in one of the new languages released today. Please visit the Microsoft Download Center pages below to download IE9 language packs.

IE9 through Windows Update for the 53 new languages released today

we will start offering IE9 to customers in one of the 53 new languages starting next week via the Automatic Update feature of Windows Update. as described earlier, we will offer IE9 via a gradual rollout and expect the rollout to be largely complete by the end of June.

IE9 language packs will also be available as an optional update via Windows Update to help users who have IE9 installed and one or more Windows Language Interface pack in the 53 new languages available today.

more Languages, faster: from IE8 to IE9

With IE9, our goal was to deliver more languages faster. more specifically, our goals included the simultaneous release of final IE9 in more languages than IE8, and a shorter interval between the final release of IE9 and the remaining languages.

Internet Explorer 8 Internet Explorer 9

  • 3 Languages for Beta 1, 25 Languages for Beta 2
  • 25 Languages for Release Candidate
  • Simultaneous release of 25 languages at general availability
  • 63 languages on Windows Vista and XP for general availability
    • 33 languages for Beta
    • 40 languages for Release Candidate
    • Simultaneous release of 39 languages at general availability
    • 93 languages for general availability
      • 14 weeks from general availability to remaining languages
        • 11 weeks from general availability to remaining languages
        • Customizing IE9 using IEAK9

          With this release, IEAK9 now supports building custom IE9 packages in all 93 languages. IEAK9 is a tool used to simplify the creation, deployment and management of customized IE9 packages. you can download IEAK9 from Please see the TechNet site for information on using IEAK9 to build custom IE9 packages.

          Thank you for using IE9 in a language of your choice, and we hope you will enjoy this release as much as we do!

          —Vishwac Sena Kannan and Kevin Luu, Program Managers, Internet Explorer

          Updated chart of languages by browser to show Opera 11.0 with 44. other minor corrections. —Ed.

          Internet Explorer 9 Now Available in 93 Languages

C++ Design Patterns Legend Joins the Visual Studio Team

Erich Gamma will start working this August as a MS Distinguished Engineer.

Gamma was lately known for his works in team effectiveness at IBM Rational Team Concert, also associated with the Java language per his key involvement with the Eclipse project. However, he was first known for leading the list of authors of the best-selling book “Design Patterns: Elements of Reusable Object-Oriented Software” –better known as the Gang of four book, as its authors’ names were abbreviated as Gang of four or simply GoF.

The GoF book, written in 1994 and winner of a Jolt award, came with many examples in C++ beside a few more in Smalltalk, having later gotten some independent “translations” to Java and C#. Therefore, it’s still today a highly influential resource in Object-Oriented Programming, both at the Academy and the CS industry.

Please welcome living legend Erich Gamma to the Visual Studio team!

C++ Design Patterns Legend Joins the Visual Studio Team

GoingNative: a New Channel 9 Show Dedicated to Native Development

GoingNative is a new, monthly show on Channel 9 dedicated to native development and native developers, with an emphasis on modern C++. in our inaugural episode, we keep things light and easy as we introduce you to what we’re doing, why we’re doing it, and how it will go down.

The main goal of episode 0 is to introduce the cast of characters, including your hosts Charles Torre and Diego Dagum, and to present some ideas of how we think this show will be organized and executed. For example, Diego and Charles will typically construct the show, iterate through some code demos of varying complexity, converse with native developers from Microsoft and across the industry, and then destruct the show. 
In this first episode we do talk about and demo a few new C++ features (shared_ptr, lambdas, auto) and have a conversation with Ale Contenti – development manager of VC’s front-end compiler, libraries, and IDE.

[You can play around with the demos in this episode by downloading the free VC++ Express IDE]

Table of Contents (click time code links to navigate player accordingly)

[00:09] Charles and Diego construct the show and talk about modern C++ (how ’bout that set, eh?)
[07:27] Diego demos shared_ptr
[10:01] Charles and Diego chat briefly about C++ lambdas
[10:32] Diego demos lambdas
[12:13] Charles and Diego chat briefly about C++ auto keyword (seen in the lambdas demo)
[13:30] Charles and Diego talk about the audience and how you can help us fly this plane
[15:32] Charles interviews Ale Contenti
[26:35] Charles and Diego destruct the show ( it won’t usually take this long )

Go native!

GoingNative: a New Channel 9 Show Dedicated to Native Development

Debugger Canvas on DevLabs

Today, we’re releasing Debugger Canvas on DevLabs.

Debugger Canvas is a new user experience for stepping through code in the debugger in Visual Studio Ultimate. it displays the code of each of the methods you step into on a canvas with call lines between them, helping you keep track of the bigger picture as well as the details.

Debugger Canvas pulls together all the code along a call path into a single display for browsing and even editing. Instead of having to keep all the code in your head while you look at one file tab at a time, now you can see the entire path on the canvas, enabling you to more easily track the flow of control and data through your application.  below, you can see an example where we have stepped into the execution of the Add Item function of a website shopping cart. the functionality requires the coordination of several methods, and the canvas lets you see them side by side so that you can more easily find and fix bugs.

Of course, the idea of showing related code together on a canvas can be useful in many scenarios. For this release, we started with debugging, since this task often involves looking at methods from many files at the same time. however, with the right options turned on, you can also navigate and edit your code from Debugger Canvas.

Debugger Canvas also highlights the potential of several of the technologies we introduced in Visual Studio 2010 Pro and Ultimate. it takes advantage of the flexibility of the new code editor to show fragments of files as bubbles on the canvas with a fully functioning editor in each. we built Debugger Canvas on top of Visual Studio Ultimate so that we could also use the underlying technology for the Dependency Diagrams to identify and display the right fragments on the canvas. This let us support both C# and VB in this release and will help us support other languages in the future. Building on VS Ultimate also allowed us to provide a new user experience for IntelliTrace, enabling some interesting scenarios, such as “show me what code ran when I clicked here”.  

Debugger Canvas is the result of collaboration with Brown University and Microsoft Research, incorporating innovative ideas from Brown’s Code Bubbles and Microsoft Research’s Code Canvas. Cutting edge research is being done at Brown and at other universities around the world to help improve development team productivity and software quality. through Microsoft Research, we collaborate with academic efforts like this one to bring innovative ideas to Visual Studio.

Take Debugger Canvas for a Spin

Our goal with DevLabs projects to get early feedback and insight and to help drive these ideas in the right direction. Try out Debugger Canvas, then bring your bugs, questions and ideas to the forum. we look forward to hearing from you!

Debugger Canvas on DevLabs

A Cloud IDE for Java Applications

Java portal and cloud user experience platform (UXP) company eXo has announced that its eXo Cloud IDE has added Cloud Foundry to its roster of supported Platform-as-a-Service (PaaS) offerings. Developers deploying Java, Spring, Ruby, and other forms of applications to Cloud Foundry can now take advantage of cloud computing’s proposition for increased agility.

A Cloud IDE for Java Applications

Adobe Flash Player 10.3: Hardware-Accelerated Rendering in IE9

Adobe Flash Player 10.3 delivers super-fast graphics by plugging into the Internet Explorer 9 hardware-accelerated rendering pipeline using IE9’s ISurfacePresenter interface. recently, some of you may have seen this rendering issue with Flash content on some pages:

Screen shots of a Web page with Flash content displayed incorrectly in its upper left corner (left) and correctly (right)

Adobe addressed the problem illustrated above (Flash content displaying in the upper left corner) in an update to Flash Player – Version will now display Flash content correctly. This update is available through Flash Player auto-update notification or at

As with any new Internet Explorer feature that we add, we want hardware acceleration to be fast, safe, error-free, interoperable and available on all computers that can run Internet Explorer. Since the start of the Internet Explorer 9 development, we worked continuously with our hardware and software partner companies to ensure that your computers are up to date with the latest bug-free drivers and software – and these partners are doing a great job of moving our entire ecosystem over to this new era in computing with minimal glitches.

your feedback as an enthusiast user has been instrumental in ensuring that we can quickly follow up on any issues with this move – thank you very much.

As always, we welcome your feedback.

—Frank Olivier, Program Manager, Internet Explorer Web Graphics

Adobe Flash Player 10.3: Hardware-Accelerated Rendering in IE9

Dealing with Conflicting Keyboard Hotkeys in Firefox

It’s been a good week for new (to me) Firefox extensions.

Any serious Firefox user will tell you that it’s all about the extensions. unfortunately, if you install enough extensions, you’ll eventually encounter a conflict between the hotkeys registered by different extensions. A few extensions are nice enough to allow you to redefine the hotkeys. most do not. I’ve been struggling with this lately – the Focus last Selected Tab and Image Zoom extensions register conflicting hotkeys – I’ve been wanting to use the FLST version, but Image Zoom was taking priority.

I just ran across the keyconfig extension, which solved my problem handily. it allowed me to suppress the Image Zoom hotkey (it can also reassign operations to a different hotkey). Problem solved.

Dealing with Conflicting Keyboard Hotkeys in Firefox