Saturday, July 4, 2009

What's the difference between Linq2Sql and ADO.Net Entity Framework

Recently, I've been looking into using ADO.Net Entity Framework with my ASP.NET MVC talks. Primarily I wanted to understand how the Entity Framework differed from Linq2Sql so I could see which technology was a better fit for my project. Here's what I've been able to come up with:

Linq2Sql is SQL-Server specific and the generated object model bears a strong resemblance to the underlying tables. In other words, there is a 1-to-1 mapping of database tables, stored procedures, etc available in Microsoft SQL Server.

Entity Framework is database-vendor independent (although you need providers) that allows the object and relational models to be quite different. Because of this you can mix a variety of database objects  to create an aggregated and combined data model.

For me, it seems that Linq2Sql is the choice for quick data access to well designed SQL Server databases where Entity Framework is the choice when a variety of data sources and data models must be combined into a single model.

I'm speaking at the Columbia Enterprise Developers Guild on 7/8/2009 in Columbia,SC

I’ll be speaking about ASP.NET MVC at the Columbia Enterprise Developers Guild in Columbia, SC on July 8th 2009. I’ll be doing my ASP.NET MVC Soup-to-Nuts talk. This presentation has few slides and focuses on code. We’ll walk through building an application using ASP.NET MVC with the goal of helping you understand why you might want to use ASP.NET MVC in your next application. I hope to see you there! More information about the Columbia Enterprise Developes Guild is available on their web site http://www.columbiadevelopers.org/ .

Tuesday, June 23, 2009

Mark your calendars, Augusta Code Camp is November 7, 2009

We’re happy to announce the first annual Augusta Code Camp to be held November 7, 2009 at  Augusta State University. Very special thanks to Dr. Todd Shultz from Augusta State University for chairing the Augusta Code Camp committee and working hard to get the web site up and running. The web address for Augusta Code Camp is http://augustacodecamp.org/default.aspx .
Attendees, speakers, sponsors, and volunteers, please register here http://augustacodecamp.org/Registration.aspx . More information will be published in the weeks to come!

Attendees have a chance to win Visual Studio Team Suite MSDN Subscription!

image

Wednesday, June 3, 2009

Why does ASP.NET MVC have to be a 'web application'? REDUX

Recently I wrote a post asking the question ‘Why does ASP.NET MVC have to be a web application?’ so here’s

Step 1: Using Visual Studio 2008, Select File->New->Project

step1

Step 2: Select the ‘ASP.NET MVC Web Application’ project template

step2

Step 3: Select ‘No, do not create a unit test project’ when prompted to create a unit test project

step3

Step 4: Close the newly created ASP.NET MVC Web Application' by selecting File->Close Solution

step4

Step 5: Select File->New->Project and under ‘Other Project Types\Visual Studio Solutions’, select Blank Solution and create an empty solution

step5

Step 6: Right-click on the newly created solution and select ‘Add->Existing Web Site’

step6

Step 7: Use the File System option to navigate to the location of the previously created ASP.NET MVC Web Application

step7

Step 8: Delete the *.csproj* files and the ‘bin’ and ‘obj’ directories.

step8

Step 9: Right-click on the web site and select ‘Add ASP.NET Folder->App_Code’, then drag-and-drop the Controllers folder into the App_Code directory

step9 step10

Step 10: Double-click on the Default.aspx file and change the CodeBehind attribute to CodeFile

step11a

step11b

Step 11: Open the Global.asax.cs file and copy the RegiterRoutes method.

Step 12: Delete the Global.asax and Global.asax.cs file. Create a new ‘Global Application Class'.’ Paste the RegisterRoutes method into the Global.asax file and add the call to the register routes method to the Application_Start method.

<%@ Application Language="C#">
<script runat="server">
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
}

void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoutes(RouteTable.Routes);
}

void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}

void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}

void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}

void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>


At this point you should be ready to go. Remember, that the reason Microsoft decided to make ASP.NET MVC projects web applications by default is to allow for unit testing more easily. Good Luck!

Monday, May 18, 2009

I'm Speaking at CodeStock on 6/27/2009 in Knoxville, TN

I was happy to learn yesterday that my ‘ASP.NET MVC - Soup to Nuts’ session has been voted IN at CodeStock. I was surprised to learn that my session was one of the top 5 sessions selected. Thanks for all of your support!Join me at CodeStock

Monday, May 4, 2009

Why does ASP.NET MVC have to be a 'web application'?

Recently I’ve been doing some presentations at user groups about ASP.NET MVC . A couple of times the question has been asked “Why does ASP.NET MVC have to be a ‘web application’?” Not having a really good understanding of why, I decided to ask the StackOverflow and ASP.NET Forums communities. I couple of people had some great theories, but I still had no definitive answer as to why. So, I decided to put the question to Scott Guthrie, I thought if anyone will know this he will. And Scott’s answer, well, it doesn’t have to be a web application. Here’s his response:

Hi Peter,

With ASP.NET MVC projects the view files (.aspx, .ascx, .master) still compile separately (they are copied as source onto the server and dynamically compiled at runtime like a web-site project). The classes within the project (controllers, models, helpers, etc) do compile into a single project-level assembly. ASP.NET MVC itself doesn’t require the application project to be a web application project (it works with web-site projects too), but we decided to have it go with web application projects by default to to enable better unit testing. By having them be a referenceable assembly a unit test project can reference the application and easily author unit tests against it. Note that Visual Web Developer Express SP1 now supports web application projects – so these are available to all users (and not just the paid products).

Thanks, Scott

Thank you Scott for clearing that up!

Monday, April 27, 2009

Development tools that I use


Here’s a list of some great development tools that I use.


  1. Microsoft Visual Studio (of course)

  2. RedGate SQL Toolbelt

  3. ReSharper

  4. Beyond Compare

  5. Notepad2

  6. Tortoise SVN and Visual SVN

  7. Snagit

  8. WS_FTP Professional

  9. XML Notepad