I'm attempting to scaffold an existing Azure database for automatically generating the context/model files in an MVVM scenario in a .NET 6, WINUI 3 project.
I'm using entityframeworkcore.tools v6.0.12 and the Package Manager Console for running the Scaffold-DBContext command. It looks something like this:
Scaffold-DbContext "Server=tcp:Server.database.windows.net, 1433;Initial Catalog=ProjectName;User ID=UserID;Password=Password;Persist Security Info=False;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
The project builds during the scaffolding, but I'm receiving this error after that:
Failed to load the dll from [C:\Users\ebagby\Desktop\Temp\DbManagerTempModel\DbManagerTempModel\bin\x86\Debug\net6.0-windows10.0.19041.0\win10-x86\hostpolicy.dll], HRESULT: 0x800700C1 An error occurred while loading required library hostpolicy.dll from [C:\Users\ebagby\Desktop\Temp\DbManagerTempModel\DbManagerTempModel\bin\x86\Debug\net6.0-windows10.0.19041.0\win10-x86]
I've scoured numerous posts/web pages with similar errors, but they don't seem to apply. Most discuss trying to run 32-bit .net but loading a 64-bit hostpolicy.dll. As you can see from the error path, I am loading a 32-bit .dll
From my .csproj file, in case it helps:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>DbManagerTempModel</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
various items...
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.12">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.221209.1" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>
...
There's not a lot of documentation that is specifically on scaffolding azure databases with .NET 6/ WIN UI 3. Most examples are sqlite, ASP.NET, XAMARIN, and so on. Perhaps I'm missing a package for Azure to bring this all together? Don't think so, but I'm grasping at straws at this point. Any help is appreciated to get this scaffolding to work.
Edit: To download the entire project, go here: https://superstructures1.sharepoint.com/:u:/s/Teams-Studio-IT/ERGX16koClJGhyIyVZRVb64BmUyrvsq9Cv7fLMMLudI_5g?e=lbM6Xs