December 06, 2012
I am trying to set a layered application with 3 projects; ASP.NET Web Forms, Business Logic, and Data Access Object using EF 5. I am using VS 2012 set to .NET 4.0 because my hosting is limited to 4.0. I have worked in VS 2005 with DataSets and using the ObjectData Source with BL with success. I am not clear how to get EF 5 to talk to BL. I have not worked with interfaces before. I have created the database then generated EF using database first. I then ran the DBcontext. In the Name_EF project I have the .edmx and the Name_EF.Context.tt and Name_EF.tt files. I am working in VB.Net. I can see all the .vb classes per table.
- Do I create an interface for the DBContext class?
- Do I instantiate the DBContext class in every one of my BL classes? Assuming a and Entity per table and a BL class per table.
- Do I write Linq to SQL to create insert, update, delete in a DAL class?
I just am not sure how to hook everything up with this architecture. I have Julia Lerman Entity Framework book but it is written for EF 4 and it is confusing trying to work with DBContext. My goal is to create generics so that this website can be easily scaled in the future. This is why I layered the application UI, BL, and DAO.