패키지 관리자 콘솔 활성화-마이그레이션 CommandNotFoundException 특정 VS 프로젝트에서만
새 프로젝트에서 'Enable-Migrations'명령을 실행하려고했는데 다음과 같은 메시지가 나타납니다.
PM> Enable-Migrations
The term 'Enable-Migrations' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verif
y that the path is correct and try again.
At line:1 char:18
+ Enable-Migrations <<<<
+ CategoryInfo : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
그러나 다른 모든 프로젝트에서는 명령이 잘 실행됩니다.
왜 이런 일이 발생합니까?
BTW, VS2010 Professional SP1을 사용하고 있습니다.
편집 : commmand : Install-Package EntityFramework -IncludePrerelease로 다시 설치했는데 문제가 사라졌습니다.
단순히 Visual Studio를 다시 시작하면 효과가있었습니다. 패키지 등을 설치할 필요가 없습니다.
commmand : Install-Package EntityFramework -IncludePrerelease로 다시 설치했는데 문제가 사라졌습니다.
이 문제는 Entity Framework가 설치되어 있지 않기 때문에 발생합니다. 아래 명령을 사용하여 Entity Framework를 설치하십시오.
Install-Package EntityFramework -IncludePrerelease
설치가 완료되면 패키지 관리자 콘솔 기본 프로젝트 드롭 다운에서 프로젝트를 선택합니다.
프로젝트의 하나 이상의 클래스가 데이터 컨텍스트에서 상속되는지 확인하십시오. 그렇지 않으면 아래 클래스를 사용하십시오.
public class MyDbContext : DbContext
{
public MyDbContext()
{
}
}
이렇게하지 않으면 또 다른 오류가 발생합니다.
No context type was found in the assembly
이러한 작업을 완료 한 후 실행할 수 있습니다.
enable-migrations
관리자 권한으로 Visual Studio를 다시 시작 하면 문제가 해결되었습니다.
Visual Studio를 관리자로 실행하고 있는지 확인합니다.
먼저 "Install-Package EntityFramework -IncludePrerelease"를 시작한 다음 Visual Studio를 관리자 로 다시 시작하면 함께 작업했습니다.
Visual Studio 2012에서 동일한 오류가 발생했습니다. NuGet을 제거해야했습니다 (도구> 확장 및 업데이트> 설치됨> 모두 : NuGet 패키지 관리자 : 제거 단추). 그런 다음 Visual Studio를 닫았습니다. 그런 다음 Visual Studio를 다시 열고 NuGet을 다시 설치했습니다 (도구> 확장 및 업데이트> 온라인> Visual Studio 갤러리 : NuGet 패키지 관리자 : 다운로드 단추). 그런 다음 다음 창에서 : 설치 버튼을 클릭 한 다음 닫기 버튼을 클릭합니다. 그런 다음 Visual Studio를 닫았다가 다시 엽니 다.
VS 2019 Preview, .Net Core 및 EntityFramework Core에서 동일한 문제가 발생했습니다.
NuGet Microsoft.EntityFrameworkCore.Tools
및 Microsoft.EntityFrameworkCore.Design
. 일단 그것이 끝나면 그것은 매력처럼 작동했습니다.
나를 위해이 증상을 수정 한 것은 (VS2013) Nuget으로 EF 패키지를 제거한 다음 다시 설치하는 것입니다. csproj 파일의 차이로 인해 변경되었습니다.
<Reference Include="EntityFramework">
<HintPath>..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll</HintPath>
</Reference>
... 여기에 ...
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll</HintPath>
</Reference>
나는 아직 그 이유를 완전히 이해하지 못했지만 적어도 효과가있었습니다.
.NET Core에서는 패키지 관리자 콘솔에 다음을 입력하여 허용 된 답변에 설명 된 것과 동일한 해결 방법에 도달 할 수있었습니다.
Install-Package EntityFramework.Core -Pre
나는 같은 문제가 있었고 다른 사람들이 제공 한 대부분의 솔루션을 시도했지만 아래 단계로 나를 위해 일했습니다. VS 2017이 있습니다.
단계 :
Install-Package EntityFramework -IncludePrerelease
그런 다음 클래스를 다음과 같이 만듭니다.
public class MyDBContext : DbContext { public MyDBContext() { } }
그리고 마지막 실행시
Enable-Migrations -EnableAutomaticMigrations
나를 위해 작동하지 않은 것 :
: VS.
: -EnableAutomaticMigrations가없는 "Enable-Migrations"명령 만.
: Nuget 패키지 관리자 복원 또는 업데이트.
처음에 내 원래 오류는
/* The term 'enable-migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.At line:1 char:1 + enable-migration + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (enable-migration:String) [], CommandNotFoundException */
I had the same problem and I found that it is because of some characters in project path like [ or ] I correct the project path and it worked fine!
Enable-Migrations -EnableAutomaticMigrations
Since I already had migrations folder, I restarted Visual Studio and ran Update-Database -verbose in package manager console. That worked for me
I tried all of the above suggestions but nothing worked for me then I updated Nuget Package Manager
and it worked..
Install Entity framework to the current project using the below command: PM> Install-Package EntityFramework -IncludePrerelease
Add a class "MyDBContext" in the Model folder as given below:
public class MyDBContext : DbContext { public MyDBContext() { } }
Now enable migrations for the current project with the below command: PM> enable-migrations
In VS 2013, try to install the UPDATE 1(RC1) and the problem is resolved.
I had multiple projects in the solution, but I had the correct Default Project set, so I thought it should work.
In the end, I had to add the -StartupProject MyProjectName
option to the command
None of these solutions worked for me. My solution was to delete packages/EntityFramework.6.1.3
and Restore NuGet Packages
I noticed that packages/EntityFramework.6.1.3/tools/EntityFramework.psd1
was missing, so this was a likely cause. How it got removed in the first place though I have no clue.
Check if config section "entityFramework" exists and described in your .config file
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/></configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
run as administrator vs =>> open opneproject
enabele-migration
add-migration migrationName
update-database
Check the version of the Entity Framework.
if it is 6.3, downgrade it to 6.2 and it should work just fine
Check if the project is open in the Solution Explorer window.
This could be the cause of your problem.
'program tip' 카테고리의 다른 글
SQL Server 저장 프로 시저의 선택적 매개 변수? (0) | 2020.08.09 |
---|---|
MySQL의 여러 테이블에서 삭제하는 방법은 무엇입니까? (0) | 2020.08.09 |
SpringData JPA에는 메서드 이름 확인을 사용하여 엔터티를 계산하는 방법이 있습니까? (0) | 2020.08.09 |
다른 사람에게 서비스로 이메일을 보낼 때 Reply-To 헤더를 사용해야합니까? (0) | 2020.08.09 |
지점 기반 변경 (0) | 2020.08.09 |