I am trying to make a simple Web API with Azure Functions (Http trigger).
In my function I want to access a SQL Server Database.
I would like to retrieve my data from the database using Entity Framework Core.
I would prefer to to use the newest versions available at the time of posting this:
I have an existing database, therefor I want to do reverse engineering using the Scaffold-DbContext command.
In order to do this I have added the following packages to my Azure Functions v3 project created in Visual Studio:
When running the Scaffold-DbContext command in the Package Manager Console I get the following error:
I found the solution to the problem.
When the project is build the project dll gets generated to the bin\Debug\netcoreapp3.0\bin folder but when you try and run the Scaffold-DbContext command it looks for it in the bin\Debug\netcoreapp3.0 folder.
Solution. Just copy the project dll to that folder and then it works.
For thr error, try to add
<PropertyGroup> <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest> </PropertyGroup>
to your .csproj file. Test whether it can be solved.
If it doesn't work, please try to create a new project under the same solution and ran the entity framework commands in that project. That should work. Then import this project to your first project, this seems an issue with azure-function.