work well in Docker but not in localhost from VS2022 (No suitable constructor BasketItem)
vRITHNER opened this issue · 5 comments
Hi,
during application setup, I executed the README.MD first step and it gave me this error:
dotnet ef database update -c catalogcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj
Build started...
Build succeeded.
System.InvalidOperationException: No suitable constructor was found for entity type 'BasketItem'. The following constructors had parameters that could not be bound to properties of the entity type: cannot bind 'catalogItemId' in 'BasketItem(int catalogItemId, int quantity, decimal unitPrice)'.
at Microsoft.EntityFrameworkCore.Metadata.Internal.ConstructorBindingFactory.GetBindings(IReadOnlyEntityType entityType, Func`5 bind, InstantiationBinding& constructorBinding, InstantiationBinding& serviceOnlyBinding)
...
the reflex is to add an empty constructor in the entity but it breaks the behavior with catalogItem = 0.
Can someone please helps me on this =?
Thanks in advance
-v
Could you run without edit the constructor
dotnet tool update --global dotnet-ef
It's maybe because you already have a previous version installed of the tool
You can also try to globally and locally unistall and reinstall (the update command install it if not yet installed)
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-tool-update
dotnet tool uninstall --global dotnet-ef
dotnet tool uninstall dotnet-ef
dotnet tool update --global dotnet-ef
dotnet tool update dotnet-ef
Hello (Bonjour Cédric ;-) de la Suisse Romande), thanks for quick feedbacks.
Sadly, when I sent the issue, I did try already all the points you did mention without success. I also restarted from scratch with no success too.
Could you pull the last version? My last pull request was accepted yesterday
Could you try on web folder
dotnet ef --version
and also outside
Wich version do you have?