Open bartvanderwal opened 1 month ago
Ik heb de package toegevoegd met:
dotnet add package Microsoft.EntityFrameworkCore.Design
Nu krijg ik een andere error, die lijkt aan te geven dat ik Entity Framework Core NuGet package (en daarmee wellicht ook meteen het 'Design' package moet installeren in de PriemCheckerLibrary
project waar ik nu ook de ..Context
en ...Repoitory
e.d. klasses heb staan in plaats van dit in WebPriemChecker
project te doen.
dotnet ef migrations add InitialCreate
Build started...
Build succeeded.
The Entity Framework tools version '7.0.10' is older than that of the runtime '8.0.8'. Update the tools for the latest features and bug fixes. See https://aka.ms/AAc1fbw for more information.
Using connection string: 'Server=localhost,1433;Database=PriemCheckDb;User Id=sa;Password=Your_password123;TrustServerCertificate=True;'.
Your target project 'WebPriemChecker' doesn't match your migrations assembly 'PriemCheckerLibrary'. Either change your target project or change your migrations assembly.
Change your migrations assembly by using DbContextOptionsBuilder. E.g. options.UseSqlServer(connection, b => b.MigrationsAssembly("WebPriemChecker")). By default, the migrations assembly is the assembly containing the DbContext.
Change your target project to the migrations project by using the Package Manager Console's Default project drop-down list, or by executing "dotnet ef" from the directory containing the migrations project.
bartvanderwal@MBP-van-Bart WebPriemChecker %
Maar als ik dit daar (in PriemCheckLibrary
project) installeer met
dotnet add package Microsoft.EntityFrameworkCore --version 8.0.8
En dan alsnog de migrations probeer te installeren dan krijg ik een error weer over mijn m2 chip:
bartvanderwal@MBP-van-Bart PriemCheckerLibrary % dotnet ef migrations add InitialCreate
Build started...
Build succeeded.
Failed to load /usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.0.5/libhostpolicy.dylib, error: dlopen(/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.0.5/libhostpolicy.dylib, 0x0001): tried: '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.0.5/libhostpolicy.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.0.5/libhostpolicy.dylib' (no such file), '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.0.5/libhostpolicy.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
An error occurred while loading required library libhostpolicy.dylib from [/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.0.5]
Okee dotnet werkt nu.
Maar nu krijg ik (na installatie EF Core in PriemCheckerLibrary als ik probeer de initiele migratie uit te voeren
bartvanderwal@MBP-van-Bart PriemCheckerLibrary % dotnet ef migrations add InitialCreate You must install .NET to run this application.
App: /Users/bartvanderwal/.dotnet/tools/dotnet-ef Architecture: x64 App host version: 7.0.10 .NET location: Not found
Learn about runtime installation: https://aka.ms/dotnet/app-launch-failed
Download the .NET runtime: https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=osx.14-x64&apphost_version=7.0.10 bartvanderwal@MBP-van-Bart PriemCheckerLibrary % ChatGPT said: ChatGPT Het probleem dat je tegenkomt lijkt erop te wijzen dat de dotnet-ef tool nog de x64 architectuur gebruikt, terwijl je een ARM64 machine hebt (M2 Mac). Dit komt vaak voor als de dotnet-ef tool in een eerdere x64-omgeving is geïnstalleerd en nu niet compatibel is met de ARM64-versie van .NET.
Oplossing: Verwijder de oude dotnet-ef tool: Voer het volgende commando uit om de bestaande dotnet-ef tool te verwijderen:
bash Copy code dotnet tool uninstall --global dotnet-ef Installeer de ARM64-versie van dotnet-ef: Installeer vervolgens de ARM64-versie van de dotnet-ef tool opnieuw:
bash Copy code dotnet tool install --global dotnet-ef --version 8.0.8 Dit zorgt ervoor dat je de juiste versie van de dotnet-ef tool hebt die compatibel is met je machine.
Controleer of de installatie correct is: Na de installatie, controleer of de tool correct is geïnstalleerd en werkt met:
bash Copy code dotnet ef --version Voer de migratie opnieuw uit: Probeer nu de migratie opnieuw aan te maken:
bash Copy code dotnet ef migrations add InitialCreate
Het maken van de initiele DB migration met commando:
dotnet ef migrations add InitialCreate
geeft een error dat ik
Design
package van EntityFrameworkCore niet heb. Zie stracktrace onder. Hoe installeer ik dit?