Saturday, July 4, 2009
What's the difference between Linq2Sql and ADO.Net Entity Framework
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
Tuesday, June 23, 2009
Mark your calendars, Augusta Code Camp is November 7, 2009
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!
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
Step 2: Select the ‘ASP.NET MVC Web Application’ project template
Step 3: Select ‘No, do not create a unit test project’ when prompted to create a unit test project
Step 4: Close the newly created ASP.NET MVC Web Application' by selecting File->Close Solution
Step 5: Select File->New->Project and under ‘Other Project Types\Visual Studio Solutions’, select Blank Solution and create an empty solution
Step 6: Right-click on the newly created solution and select ‘Add->Existing Web Site’
Step 7: Use the File System option to navigate to the location of the previously created ASP.NET MVC Web Application
Step 8: Delete the *.csproj* files and the ‘bin’ and ‘obj’ directories.
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
Step 10: Double-click on the Default.aspx file and change the CodeBehind attribute to CodeFile
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
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.