Can I make a WebAPI that uses EF6, in Azure?

Rod Falanga 531 Reputation points
2021-05-02T19:25:36.003+00:00

At work we write new apps using .NET 4.5.2 and EF6. I'm wondering if I can write WebAPIs that will run in an Azure App Service with .NET 4.5.2 and EF6? Or are Web APIs in Azure App Services only for CORE 3.x and 5?

Entity Framework 6.0
Entity Framework 6.0
A Microsoft open-source object-database mapper for .NET.
218 questions
Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,090 questions
No comments
{count} votes

Accepted answer
  1. Duane Arnold 3,211 Reputation points
    2021-05-03T00:33:21.967+00:00

    @Rod Falanga

    1) EF Core 5 works with .NET Framework 5.0 that is a Core .NET Framework. .NET 5 is Core.

    2) You can use ASP.NET WebAPI 2 using .NET 4.5.2 that will work with EF 6.

    3) This time, you can use a classlib project to hold the DTO(s) that is using .NET 4.5.2, and you should leave the DTO(s) at the WebAPI as discussed in the EF Core forum.

    You should try to implement seperation of concerns with the WebAPI referencing the DAL using the DTO and DAO patterns for CRUD operations with EF.

    https://javarevisited.blogspot.com/2013/01/data-access-object-dao-design-pattern-java-tutorial-example.html

    Here is a solution out on Github that is using a .NET 4.x framework, WebAPI 2, EF 6 database first and DTO and DAO patterns, but it is was done in VB.NET.

    https://github.com/darnold924/ProgMgmntVB

    As couple of other things about logging in WebAPI, which is being shown in the which is also be shown in the code example in the EF Core forum concerning the shown project code.

    DI is being used in both solutions being shown in the two forums.

    https://ardalis.com/new-is-glue/

    https://stackify.com/csharp-catch-all-exceptions/


1 additional answer

Sort by: Most helpful
  1. Ken Kam Hung, Lin 6 Reputation points
    2021-05-03T06:40:54.503+00:00

    Azure App Service is just like an IIS WebSite but in Azure.
    You could do local development with .NET 4.5.2 and EF 6, Target as WebAPI in local IIS first. Then you could create Azure App Service and ftp your compiled files to it. Or saving your source code to GitRepo/Github and then using Azure DevOps to do the Azure pipeline to deploy it.

    Some links here are useful for you to read.

    Create WebAPI with EF6
    https://learn.microsoft.com/en-us/aspnet/web-api/overview/data/using-web-api-with-entity-framework/part-1

    Deploy to Azure App Service
    https://learn.microsoft.com/en-us/azure/app-service/deploy-run-package
    from there you can also found the other options, via ftp, via cloud sync, CI/CD, Azure DevOps, from Local Git....etc

    No comments