N-Tier and Entity Framework

My first steps moving away from just putting everything in each web page were rough. So, now I am trying to create an organized N-Tier web app. There is lots of discussion of this all over the web, and each person seems to set things up a little differently, depending on what problem they are trying to solve. After some exhaustive research, I have decided to go down this path, and I hope that this basic structure will work for future apps without two much trouble.

Data Tier: SQL Server 2005 – I didn’t have any choice here. This is what my company uses. They are planning on switching to 2008 soon.

Data Access Tier: Entity Framework 5 – At this point I am gonna stick with Microsoft as much as possible. I am using the DbContext API. I have bounded contexts, with each context being a separate Visual Studio project. I have an additional ‘Migrations Context’ for Code First Migrations. Oh yes, I am using Code First.

Repository Tier – This is where my Linq will reside. I am using Dynamic Linq in a few locations, to allow the user to design some queries for themselves. Also a separate Visual Studio project.

Business Tier – This is the actual business logic of the application. This layer is entirely Entity Framework independent. Also a separate Visual Studio project.

User Interface Tier – These are the .aspx pages.

Entities – These are the POCOs that hold that hold the actual data. You guessed it… a separate Visual Studio project.

Each tier can only access the tier immediately above of below it, except the entities, which are available to any tier. Future posts will discuss how I structured each tier.

Some Links:

Data Access Tier is based on ideas suggested by Julie Lerman: http://msdn.microsoft.com/en-us/magazine/jj883952.aspx

I went with the repository pattern because of this: http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application

Advertisements

3 thoughts on “N-Tier and Entity Framework

  1. Sounds like you’ve got it cracked and you’re right to dive in and start putting something together. There’s so much information out there that it’s easy to get bogged down. Is this a public facing application or is it an internal one? I was wondering if you had to deal with scaling out at all.

    • OK, 1. I guess I don’t understand word press that well. How did you find this already, I just posted it? 2. Its still in development, but it also will not be public facing. 3. Not sure about scaling it out yet.

      • Haha, yeah I’m pretty new to all this too tbh. I like to seek out posts that are tagged with technology and programming because I’m always fascinated by the sort of stuff people are doing. There are some awesome coders out there doing some really original stuff and you get to see it through their blogs.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s