0

After having problems using the Entity Framework tools nuget package (EntityFrameworkCore.Tools) in my WINUI 3 solution to generate the model files using the Package Manager Console, I figured I'd try using a new, blank solution to generate the files.

That had the same problem, making me wonder if the approach works with WINUI 3.

The approach I took was:

  1. Created a new project/solution: Blank App, Packaged (WINUI 3 in Desktop)

  2. Added packages EntityFrameworkCore.SqlServer and EntityFrameworkCore.Tools

  3. Opened the Package Manager Console and set the directory to the project

  4. Used the following in the console (credentials and names made generic):

    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 will not build. I get an error shown below. Being a new project, I figure there must be something wrong with the process, even though I've referenced multiple documents and video instructions. Admittedly, some of these were for UWP or Xamarin since the WINUI instructions seem to be scant.

So my question boils down to this: is my process wrong, or is there a different approach for WINUI 3 projects?

Error APPX1101
Payload contains two or more files with the same destination path 'DbManagerTempModel.deps.json'.
Source files:
C:\Users\ebagby\Desktop\Temp\DbManagerTempModel\DbManagerTempModel\obj\x86\Debug\net6.0-windows10.0.19041.0\win10-x86\DbManagerTempModel.deps.json
C:\Users\ebagby\Desktop\Temp\DbManagerTempModel\DbManagerTempModel\bin\x86\Debug\net6.0-windows10.0.19041.0\win10-x86\DbManagerTempModel.deps.json

DbManagerTempModel
C:\Users\ebagby.nuget\packages\microsoft.windowsappsdk\1.2.220902.1-preview1\buildTransitive\Microsoft.Build.Msix.Packaging.targets 1480

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
E. A. Bagby
  • 824
  • 9
  • 24
  • 1
    I have no problem x86 or x64. See my config https://i.imgur.com/0CJbMYa.png make sure you're using the latest WinAppSDK and build tools and EF packages corresponding to your framework. I've used .NET 6 and EF packages 6.x – Simon Mourier Jan 03 '23 at 18:25
  • OK. so updating to the latest stable SDK.BuildTools and WindowsAppSDK allowed it to build. But now I get the following error. I suppose I need to make a new post: 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\] – E. A. Bagby Jan 03 '23 at 19:01
  • Not sure how you get that error, I don't have any error when I run the app, it just displays the "click me" button and I can click it. – Simon Mourier Jan 03 '23 at 21:07
  • Is your an Azure SQL database? If so, do you need to add a package or anything for Azure to tie it all together? I just wrote another post on this problem: https://stackoverflow.com/questions/74998619/scaffolding-azure-database-in-net-6-winui-3-project-fails-to-load-hostpolicy-dl – E. A. Bagby Jan 03 '23 at 21:09
  • 1
    You should start by closing this question or answer it with your findings. My database is a local SQL Server but I'm pretty sure this is irrelevant, would be the same with Azure. hostpolicy is from .NET, not EF or satellites. – Simon Mourier Jan 03 '23 at 21:15
  • Added my answer. Thanks for the info on hostpolicy. It helps me scratch the surface a little deeper. – E. A. Bagby Jan 03 '23 at 21:25

1 Answers1

0

To get past the payload problem, I checked the versions of the packages.

I set EntityFrameworkCore.SqlServer and EntityFrameworkCore.Tools to version 6.x to match .NET 6 (they were at version 7.x).

I also updated SDK.BuildTools and WindowsAppSDK to the latest stable versions.

E. A. Bagby
  • 824
  • 9
  • 24