Search code examples
asp.netangularjsasp.net-web-apiprojects-and-solutionsasp.net-core

Solution structure for ASP.NET 5


We are a small dev team that has inherited a decent sized ASP.NET MVC project started a few years ago with ASP.NET 4. We are looking to migrate to ASP.NET 5 at some point. Currently the solution has 3 projects - Data, Services, Web. The data project uses the Entity Framework. The Web project previously was just MVC but now houses a Web API where we have a couple hundred RESTful API calls and an AngularJS frontend.

It looks like the ASP.NET 5 default solutions for web applications uses a new structure with the web project containing wwwroot and other things. Would you recommend having multiple projects or should we keep the data and services in the main project? I'm leaning towards the single project approach, but I'm unsure what the best long term structure would be. Thanks!


Solution

  • One solution, many projects. The point is to separate reusable components of your project. In fact, I'd add one more project to the ones you listed in your question. Models.

    Let's say you decide to add another application to your solution. It might be a Xamarin Forms app, a WPF app, console app, Windows service, whatever. If your Models and Data Layer are each in their own class library, you can reuse them without needing to duplicate code. If you had put your models and data layer in your Web API project, you wouldn't be able to reuse it in your new app easily.

    The only thing that I wouldn't necessarily (thought I still might) combine is the Web API app and the Angular app. Those two are probably so intricate that it makes sense to keep them in one project.