functions-csharp-entityframeworkcore
functions-csharp-entityframeworkcore copied to clipboard
C# Function that uses dependency injection and entity framework core with Azure SQL
Interested in .NET 5?
Link to a sample using Entity Framework 5 in Azure Functions: https://github.com/jeffhollan/functions-net5-entityframework
.NET Core Entity Framework and functions
C# Function that uses dependency injection and entity framework core with Azure SQL. A few things of note:
I want to use design-first migration, so I created a IDesignTimeDbContextFactory for the tooling to generate the right DbContext.
I also had to add a post-build step to the .csproj file to make sure the .dll for the project is where the entity framework tooling expected:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y "$(TargetDir)bin\$(ProjectName).dll" "$(TargetDir)$(ProjectName).dll"" />
</Target>