I have Visual Studio for Mac and I'm trying to learn Xamarin with Azure using the following tutorial: https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter3/server/
At some point, I have to enable EF migrations. The tutorial says: Go to View -> Other Windows -> Package Manager Console.
Unfortunately there is no Package Manager Console in Visual Studio for Mac... so how do you handle things like enable-migrations
, add-migration
or update-database
on the Mac?
From the Tools menu, select NuGet Package Manager > Package Manager Console. The enable-migrations command creates a Migrations folder in the ContosoUniversity project, and it puts in that folder a Configuration. cs file that you can edit to configure Migrations.
Add-Migration - The Term 'Add-Migration' Is Not Recognized After creating models and context class, we nomally add migration to initialize the database. The error occurs sometimes while adding migration in asp.net core, entity framework with code first approach because of some missing library.
Adding a Migration So, firstly, you need to create a migration. Open the Package Manager Console from the menu Tools -> NuGet Package Manager -> Package Manager Console in Visual Studio and execute the following command to add a migration.
To run EF on Mac just follow the following.
Open a command line, go to the project folder, and run
dotnet restore
If everything is fine, you should be able to run
dotnet ef
After that you can run commands like:
dotnet ef migrations add initial
dotnet ef database update
This is currently supported on Mac.
First you need to install dotnet-ef
dotnet tool install --global dotnet-ef
To install a specific version of the tool, use the following command:
dotnet tool install --global dotnet-ef --version 3.1.4
Add the "dotnet-ef" tools directory on the PATH environment variable.
export PATH="$PATH:/Users/'your user folder'/.dotnet/tools"
Open a command line, go to the project folder, and run
dotnet restore
If everything is fine, you should be able to run
dotnet ef
After that you can run commands like:
dotnet ef migrations add initial
dotnet ef database update
PS: Your solution should not be executing when the dotnet ef command line is trying to run!!!
For People who are not convinced, here a demo of succeed!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With