.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:
Windows
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y "$(TargetDir)bin\$(ProjectName).dll" "$(TargetDir)$(ProjectName).dll"" />
</Target>
Mac
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="cp "$(TargetDir)bin\$(ProjectName).dll" "$(TargetDir)$(ProjectName).dll"" />
</Target>