First Looks @ AWS Toolkit for Visual Studio 2010

I’ll be presenting on the AWS Toolkit for Visual Studio 2010 in the very near future (Check out the SAWSUG Meetup on October 12th, that’s this Wednesday). I’ll be covering a number of things about the new AWS Toolkit for Visual Studio. My slides are available below (with links to the Google Docs and Slideshare Versions).

[googleapps domain="docs" dir="present/embed" query="id=dgvssh3q_418chn3jg4r" width="410" height="342" /]

Direct link to Google Docs Presentation or the SlideShare Presentation.

The code for the presentation is available on Github under AWS-Toolkit-Samples. Beware, this code will be changing over time, the core will stay the same though.

Widgetz SQL Server DB + ASP.NET MVC 3 Web Application Scaffolding

This is a quick walk through of how to setup a database, create some model objects, and build a scaffold for CRUD (Create, Read, Update, and Delete) all using ASP.NET MVC 3 and Visual Studio 2010.

Open Visual Studio 2010 and start a database project as shown.

SQL Server 2008 Database Project in Visual Studio 2010 (Click for full size image)
Next create an ASP.NET MVC 3 Web Application in this solution.

ASP.NET MVC 3 Web Application (Click for full size image)
Now open the Server Explorer in Visual Studio 2010 (You might have to click on View to find it if it isn’t already available in the main IDE). Right click on the Data Connections node in the Service Explorer Tree. Select Create Database and provide a name for the database.

Create a New SQL 2008 Database

New Database Dialog
Next in the Server Explorer, right click on the newly created database and select New Query. Then in the query window paste this SQL create script in and run it by right clicking and selecting execute.

[sourcecode languag=”sql”]
CREATE TABLE [dbo].[Widgetz] (
[Id] UNIQUEIDENTIFIER NOT NULL,
[Name] NVARCHAR (50) NOT NULL,
[Description] NTEXT NULL,
[Created] DATETIME NOT NULL,
[Terminated] DATETIME NULL,
[Addon] BIT NOT NULL,
[Active] BIT NOT NULL,
[Cost] MONEY NULL,
[ChildWidgetz] INT NULL
);

ALTER TABLE [dbo].[Widgetz]
ADD CONSTRAINT [PK_Widgetz] PRIMARY KEY CLUSTERED ([Name] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF);

ALTER TABLE [dbo].[Widgetz]
ADD CONSTRAINT [DF_Widgetz_Created] DEFAULT (getdate()) FOR [Created];

ALTER TABLE [dbo].[Widgetz]
ADD CONSTRAINT [DF_Widgetz_Active] DEFAULT ((1)) FOR [Active];

ALTER TABLE [dbo].[Widgetz]
ADD CONSTRAINT [DF_Widgetz_Addon] DEFAULT ((0)) FOR [Addon];
[/sourcecode]
Once the table is created bring to focus the Solution Explorer and right click on the Database Project, selecting the Import Database Objects and Settings.

Import Database Objects and Settings…
Next select the correct database connection, and leave everything else as it is set.

Selecting the appropriate database, options, and click next… (Click for the full size image)
Next the wizard will finish importing the database objects.

Finished (Click for full size image)
If you look through the folder tree of the project you’ll find individual files for the table, defaults, and other object settings.

Now right click on the Models directory of the ASP.NET MVC 3 Project that was created earlier. Select add and then new item. In that dialog add a new ADO.NET Entity Data Model.

Yup, just when you think it had gone away… ADO.NET (Click for full size image)
A dialog will appear, select the option to Generate from database and click next.

Entity Data Model Wizard (Click for full size image)
Next select the correct database connection again, then click on Yes to save the sensitive data (which if you’re using windows authentication it isn’t really going to save anything dangerous). Make sure the entities are named appropriately and click Next.

Options for Creating the ADO.NET Entity Model
The next screen, which may take a moment or two to display the list of tables and objects, will appear. Select the table that has been created and click on

Entity Data Model Wizard (Click for full size image)
Once done and finish is clicked, the entity model file will show the display view of the entity that was just created.

Entity Model
Now right click on the controller folder and select to create a new controller.

Add Controller (Click for full size image)
Be sure to click the advanced options and select the layout page.

Advanced Options (Click for full size image)
Now click on Ok and then Add. Visual Studio 2010 will not generate the scaffolding for the controller and views around CRUD operations.

The Scaffolding in ASP.NET MVC 3
This might seem like an absurdly easy thing to do, and you’d be right. There are however many steps to turn this into a feasible, well design user interface, and provide a solid and intelligent user experience (UX) to the end user. Also, this is arguably a not so maintainable bit of work. If the end user ONLY wants to operate on the data with CRUD, then this is great. But the minute something else is needed a very different, testable, and maintainable architecture should be utilized instead of this generated scaffolding. Which in coming blog entries I will be covering some of the ways to create testable, maintainable, and better designed architecture around more than CRUD. 🙂

CODE: All the code for this project is available in the Lesson 1 – ScaffoldGeneratedWidgetz.

My Current Windows Development Machine Software Stack

I recently did a clean install of Windows 7 64-bit. It had been a really long time since I listed the current tools, SDKs, and frameworks that I’ve been using. Thus here’s my entourage of software that I use on a regular basis that is installed on my primary development machines.

Amazon Web Services ~5 Minute .NET Quick Start

This is the beginning of a series of blog posts I’m putting together on building out a website on Amazon’s Web Services. This is a quick start on where to find the .NET SDK, what templates are installed in Visual Studio 2010, and what you get when starting a new Web Application Project with the AWS .NET SDK.

VS2010 Tools (These Are Awesome, Get em’)

I’m a little late to this party, but thanks to Somasegar’s “VS 2010 Productivity Improvements, Part IV” and Mathew Johnson’s “Changing Visual Studio’s Color Palette” on the Visual Studio Platform Blog. I’ve now got Visual Studio looking like this: (Click on the image to view full size)

I picked up the Embers Theme on studiostyles which I found easy on the eyes, but without some of the color bleed that the other theme Somasegar suggested. However, everyone’s eyes are a bit different, so pick and choose as you will.

The classes and methods shown with color coding on the left hand side of the code window is done with VS10x Code Map. The image below shows the code window with the code map showing. This can be really handy when you have a large class file or are just trying to navigate around the file easily. (Click on the image to view full size)

The next tool that is a must have is the Visual Studio 2010 Pro Power Tools. Some of the key features for this tool include:

Document Well – If you aren’t sure what this is, go check out the more info. This is a pretty awesome feature, the download is worth this alone!
Searchable Add Reference – Everyone needs this at some point in time or another. It is a huge pain in the ass to find references, this resolves 99% of that pain!
Ctrl+Click Go To Definition – Yes please, thanks! I want my hands on the keyboard, not the mouse. :/
Another tool…