Imeguras
Imeguras

Reputation: 443

Is there a way to use EF migrations through CLI on .NET Framework 4.8

So basically im trying to do my first application/backend system on EF 6.0 the thing is that due to nomenclature's i started confusing .NET and .NET framework and by the looks of it im not alone causing what seems like a bunch of issues.

Im doing code first and i want my models to be automatically turned into sql tables on a azure sql database, but after trying to run add-migration he complains about needing a config file first so i decided to install ef globally through the cli instead of nugget console manager and then ran dotnet ef migrations script -i but it complains about circular dependacies involving "GetEFProjectMetadata". and after bigging through google all of the migrations seem to use .net core 6.0

So do i need to once again migrate my whole project to .net core 6.0? or is there a way to use .net framework 6.0?

If the question came rushed or i didn't detail enough info, im sorry, as i tipically work in linux and my system is in my native language so translating would either be somewhat time consuming or wouldn't be the 1:1 error message

Edit:

here's the error i was refering to:

(*drive path up to user*)\OneDrive\Documents\Visual Studio 2022\Projects\MakrBackend(solution root, it was refactored to Makr-Backend once though strangely it didn't change the actual folder name)\Makr-Backend(project)\obj\Makr-Backend.csproj.EntityFrameworkCore.targets(4,5): error MSB4006: Há uma dependência circular no elemento gráfico de dependência circular de destino envolvendo o destino "GetEFProjectMetadata". [(*drive path up to user*)\OneDrive\Documents\Visual Studio 2022\Projects\MakrBackend\Makr-Backend\Makr-Backend.csproj]
Unable to retrieve project metadata. Ensure it's an SDK-style project. If you're using a custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.

To reproduce it in my machine i just go to show->terminal which apparently opens an embuted power shell in which i write dotnet-ef migrations add InitDB dotnet was installed globally and writting dotnet-ef replies me with some simple ascii hart of an unicorn along with some generic help suggestions and arguments info

As suggested earlier the solution was wiped several times due to me not being able to use Entity framework, the latest try i decided to not put the hypen (Makr-Backend) due to fears of data persistance as such later in the project i renamed the solution to Makr-Backend and created a new project with the same name, although i deleted the project without a hyphen im aware that he still is present in the root directory although i tipically make shure im not adressing that folder, the only reason i haven't whiped it out of the system is that it contains the graphs i was intending to use as a model for the database

Another Edit apparently entity framework and entity framework core are radically different things and I've finally managed to do what i wanted by migrating the project to .net core and using exclusively a entity framework core aproach and i finally managed to populate my azure database

Upvotes: 3

Views: 1794

Answers (1)

D.Fernandes
D.Fernandes

Reputation: 130

"dotnet ef" is the cli tool for Entity Framework Core. Don't confuse it with Entity Framework.

You don't necessarily need to upgrade your app to .NET 6 You can check the Entity Framework Core documentation on the supported versions.

Also I believe this article will help you better understand the naming.

Upvotes: 1

Related Questions