Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I share DAL and BLL across multiple .NET applications?

I need to create several applications that all share a Microsoft SQL Server database. These include ASP.NET web applications, WPF desktop applications, and probably the odd console app every now and then.

I'd like to use the ADO.NET Entity Framework for data access, extend its objects for my business logic, and bind those objects to controls in my UI.

How can I do this in each of my applications without repeating myself too much? If the database schema or my business logic changes, then I want an easy (or automatic) way to update all my applications.

How should I architect this system?


Update: I've asked follow-up questions...

  • How do I use LINQ to Entities in Visual Basic?
  • How do I extend ADO.NET Entity Framework objects with partial classes?
like image 919
Zack Peterson Avatar asked Nov 03 '08 19:11

Zack Peterson


3 Answers

for that I would recommend creating a Visual Studio Solution that contains multiple Projects. Your DAL would be contained within its own project then for the other projects that need to make use of that functionality, create a Project Reference back to the DAL project.

Hope this helps!

like image 181
Adam Alexander Avatar answered Oct 22 '22 09:10

Adam Alexander


adamalex's idea is sound. depending on your setup, another favoured approach is to take the common projects separate, compile and then have your other projects reference this compiled dll. it is up to you if they reference the latest build of this dll or a specific version of it. perhaps you don't want some projects having to keep up all the time.

like image 21
dove Avatar answered Oct 22 '22 10:10

dove


Maybe you can use webservices to centralize the database access / logic...

As seen in the answers from link (SOA / WebServices / Remoting)

like image 45
bob Avatar answered Oct 22 '22 09:10

bob