Using MVC or Web API for Restful APIs in .net CORE

Hey all,

I am working on redesigning our main CRM for a rewrite.  We are primarily a .NET shop so I am thinking MVC for the front end, but I am trying to figure out the best design approach for the middle tier (business logic).  I am pretty sure I want to expose the data layer via a restful API, so WebAPI on .NET CORE seems to be a good fit.  

In my research, I had a couple question.
  1. As I delve more and more into MVC, it seems that could just as easily return an "object" from a controller as I could a view.  If that is the case, is there any reason not to just include my API logic in the MVC application instead of making a separate project?
  2. I have learned that I can use scaffolding to generate classes automatically from the database, is there a way to automatically generate controllers for my classes?
  3. (I know this one is pretty general) Are there other/better technologies I should be looking at?

Thanks in advance.
MRSAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ambienceCommented:
1) API logic is better kept outside the controllers but it doesnt have to be put in a separate project. Though, the presence of a particular reason that requires it to be part of the MVC application (project) can be code smell. API logic, if put inside say Services leads to better reusabiity and testing.

One of the SOLID principles is that there should be only one reason for modifications to a class (single responsibility). We can extend that principle to project structures and logical units. If API logic and UI logic exists in the same project there there are multiple reasons to change the project. Keeping API logic in a separate project isolates it from UI specific changes.

3) Rest implementations like GetAllBooks often mutate quickly enough as you find yourself needing complex querying logic for different purposes. Unless your needs are simplistic you may want to look into the rich querying capabilities of OData, which is built on top of REST. Related:

https://docs.microsoft.com/en-us/aspnet/web-api/overview/odata-support-in-aspnet-web-api/odata-v4/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MRSAuthor Commented:
thanks for all the great info.  Are you aware of any release date for OData for AspNetCore?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET MVC

From novice to tech pro — start learning today.