1.5. Move the Data Context to a Separate Assembly

Often web applications architecturally consist of more than just the user interface layer, or the ASP.NET web site project. Most Dynamic Data demonstrations guide developers to place the database models in the App_Code folder. This practice violates modern programming practices of "not mingling user interface code with application code."

The following exercise will remove the data context from the user interface layer into a class library. Placing the database models at this level allows the web site as well as a Web Service, client application, console application, or any other type of UI layer to harness the business logic in the data context.

Begin by adding a new project to the solution by ...

Get Secrets of Real World ASP.NET Dynamic Data Web Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.