August 2011 - Posts

Let's be frank...Most of us developers have it pretty good. We happen to have hung our hats on an industry that has plenty of work, even in the midst of a protracted recession. (Okay, this might not be true for every developer but as a general rule, employment for software professionals is better than many other sectors. If you are currently unemployed, I wish you the best in locating a job.)

We possess unique and valuable skills that would be valuable to charitable organizations if they just could afford to hire us.

Now woudn't it be nice if there was a low-barrier, low-pain, short-term-commitment way to hook up worthy non-profits with software professionals to crank out a few apps in a short amount of concentrated time? Well there is and it's called GiveCamp!

GiveCamp is a weekend-long event where software developers, project managers, designers, database administrators, and other software professionals donate their time to create custom software for non-profit organizations. The next National GiveCamp is being held October 21-23 in 20+ cities.

I am leading the Seattle instance of GiveCamp. If you are in the Seattle area (or close enough to drive to Seattle) and are a software professional, we'd love to have your help in helping a great bunch of charities. You can volunteer here. (BTW, we need both technical and non-technical volunteers.)

[And if you are part of a charity (or know a worthy charity) that might be interested in applying for help at Seattle GiveCamp, you can submit an application here. But hurry so you can get your app in by our deadline (first deadline is Sept 15; last deadline is Oct 7).]

And if you are not in the Seattle area, but still want to help, please check out the National GiveCamp site where you can find the closest GiveCamp with which to hook up (charities can go here too to find an event in your locale).

Note that your volunteer committment is only for 1-3 days. That's it. GiveCamp is not about supporting the apps you work on for life. (Of course, if you want to make a longer-term committment, I'm sure the charities will be happy to sign you up outside of the event--but that's not what GiveCamp is about.)

With your help, we can make National GiveCamp a success that we can all be proud of! Thank you.

I will be presenting three sessions at Microsoft ASP.NET Connections, one of the conferences that is part of DevConnections. Two of my talks are especially targeted at ASP.NET Web Forms developers who are in the process of learning or coming up to speed with ASP.NET MVC.

On Wednesday, November 2nd at 11:30 AM I will be delivering ASP.NET MVC 3 in 75 Minutes. This talk is especially suited for MVC neophytes. Check out the abstract...

Trying to come up to ASP.NET MVC in a hurry? The session will begin with a brief introduction to ASP.NET MVC 3. During the remainder of the session, Paul will present a series of step-by-step demos, building a data-driven ASP.NET application utilizing the Razor View Engine, LINQ, and the Entity Framework. The demos will cover creation of a data model with Entity Framework 4.1, the population of select controls, the incorporation of input validation, unobtrusive JavaScript, jQuery, remote validation, and more.

Then at 3:45 PM that same day I will be delivering another interesting session entitled Lightning Development with MVC Scaffolding. Here's the session abstract....

Steve Sanderson and Microsoft have created an amazing Nuget package called MVC Scaffolding. This package with a very unasuming name is packed with features to help you develop ASP.NET MVC applications rapidly. This session will get you started using MVC Scaffolding with a series of demos that illustrate the scaffolding controllers, views, data models, tests, and lots more. During this session, you’ll learn how to scaffold various parts of your MVC apps, change scaffolding defaults, and even modify the scaffolding templates used by MVC Scaffolding.

During this talk I will show you how to use MVC Scaffolding for both CodeFirst and DatabaseFirst development. If you are interested in the latter, see my blog post on this topic.

Not ready to make the jump to ASP.NET MVC? I will also be presenting a Web Forms talk as well: What's So Funny About Peach, Love, and Server Controls? It's a light-hearted title, but the topic is nonetheless very important. I'll be giving this talk on Thursday, November 3 at 9:30 AM. Here's the abstract...

Server controls are both the good news and bad news for Web Forms developers. They can be quite good because their rich event model makes things so easy. But they can also be very bad once you start pushing their inconsistent programming model. In this session, Paul will explore in depth the "out-of-the-box" data-bound server control event model, make sense of the programming model, and show you how to maximize your use of the data controls while minimizing your pain.

Of course these are just my talks. There are lots of other talks on MVC and Web Forms at varying levels. Plus lots of talks on WPF, Silverlight, SQL Server, Windows Phone 7, HTML 5, Exchange, and Windows.

Hope to see you there!

Microsoft ASP.NET Connections

Steve Sanderson's MVC Scaffolding NuGet package is awesome and goes far beyond the very good scaffolding available from the Add Controller dialog in Visual Studio 2010 (after installing the MVC 3 Tools Update).

But a shortcoming of MVC Scaffolding is that, out of the box, it works only in Code First mode. However, with a little finagling you can get it work in a database first scenario. I'm sure there are several different ways to do this but here is what I did that was pretty easy. This assumes the database schema has already been created using SQL Server.

  1. Add an ADO.NET Entity Data Model to the Models folder of your ASP.NET MVC 3 application.
  2. Select Generate from database from wizard and generate the entity model for your database objects.
  3. Right-click on the .edmx model file and select Add Code Generation Item... from the pop-up menu.
  4. Under Code tab of dialog, select ADO.NET DbContext Generator. This changes the EF model to use DbContext instead of ObjectContext and creates a DbContext class for the database, by default, with the name databaseEntities. For example, I have a database named BPath. So for this database, EF creates a DBContext class named BPathEntities. This step is key because it will make the database-first classes you generate compatible with the code-first classes that MVC Scaffolding generates later.
  5. Now use MVC Scaffolding to generate the controllers for your app utilizing the entity classes that the DbContext generator generated for you in step #4, which, by default, will have the same name as the tables/views from your database that you selected in step #2.
    For example, in my database I have a table named Participant so I would enter
    Scaffold Controller Participant -force -repository
    into the Package Manager Console to scaffold a controller and views for the Participant entity from the model. The -force option overwrites any existing items and -repository creates repository classes for the entity.
  6. Now open the repository class that MVC Scaffolding created. It will be named, by default entityRepository. So in my example, I would open ParticipantRepository in the code editor in Visual Studio.
  7. Now you will note that MVC Scaffolding created a different DbContext for itself named, by default, projectnameContext that it references in the ParticipantRepository class.
  8. Change the context statement so it now uses instead your db-first context instead of MVC scaffolding's code-first context.

In my example, I have commented out the code-first context named BPathMVCContext and replaced it with the database-first context named BPathEntities:

ParticipantRepository Class Changes

Repeat the process for any additional controllers and you are done. Hope this helps.

More Posts