2017-09-20 8 views
3

가 나는 코드 첫 번째 프로젝트에, 엔티티 프레임 워크 코어에 대한 마이그레이션을 추가하는 동안 오류를 받고 있어요는 "EntityFramework 패키지가 설치되지 않은"여기EntityFramework 코어 2.0 - 마이그레이션 오류를 추가

... 세부 사항입니다

새로운 ASP.Net Core 웹 프로젝트 (VS2.07의 Core 2.0)를 만들었습니다. 그것 Microsoft.AspNetCore.All 종속성을 사용하여, 다음과 같이 : 내가 엔티티 프레임 워크 코어를 활용 찾고 있어요

enter image description here

(나의 이해는 모든 메타 데이터는 EF 코어 종속성이 이미 아래와 같이 포함했다고했다) 올바른 것으로 보인다 :

enter image description here

내가 설정 내 엔티티와 컨텍스트를했고 나는 다음과 같은 코드를 사용하여 설치를 dB이다 보장했습니다.

예 모델

public class City 
{ 
    [Key] 
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)] 
    public int Id { get; set; } 

    [Required] 
    [MaxLength(50)] 
    public string Name { get; set; } 

    [MaxLength(200)] 
    public string Description { get; set; } 
} 

예 컨텍스트

public class CityInfoContext : DbContext 
{ 
    public DbSet<City> Cities { get; set; } 
    public DbSet<PointOfInterest> PointsOfInterest { get; set; } 

    public CityInfoContext(DbContextOptions options) : base(options) 
    { 
     Database.EnsureCreated(); 
    } 
} 

Startup.cs 구성

public void ConfigureServices(IServiceCollection services) 
{ 
    services.AddMvc() 
    .AddMvcOptions(options => { 
     options.OutputFormatters.Add(new XmlDataContractSerializerOutputFormatter()); 
    }) 
    .AddJsonOptions(options => { 
     if (options.SerializerSettings.ContractResolver != null) 
     { 
      var res = options.SerializerSettings.ContractResolver as DefaultContractResolver; 
      res.NamingStrategy = null; 
     } 
    }); 

    services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); 
    services.AddSingleton<IMailService, LocalMailService>(); 

    // Entity Framework services. 
    var connectionString = @"Server=(localdb)\mssqllocaldb;Database=CityInfoDB;Trusted_Connection=True;"; 
    services.AddDbContext<CityInfoContext>(options => options.UseSqlServer(connectionString)); 
} 

의 INI 내 컨트롤러에이 줄을 사용하여 DB를 conext을 tializing :

public class DummyController : Controller 
{ 
    CityInfoContext _ctx; 

    public DummyController(CityInfoContext ctx) 
    { 
     _ctx = ctx; 
    } 
} 

나는 dB가 성공적으로 만들어 볼 수 있습니다 - 모든 좋은 지금까지.

enter image description here

나는이 명령을 사용하여 내 DB의 스냅 샷을 할 : 오후> 오류 CityInfoInitialMigration

마이그레이션을 추가하지만, 얻을 : EntityFramework 패키지가 프로젝트에 설치되지 않습니다 'CityInfo.API'.

enter image description here

사람이 전에 건너 온 적이 있습니까? 명시 적으로 EF 패키지를 추가하려고했지만 그 중 하나가 작동하지 않았습니다! `은 Get-모듈을 무엇을 ...

https://docs.microsoft.com/en-gb/aspnet/core/data/ef-mvc/migrations#introduction-to-migrations

+0

그것은 실행중인 EF6 PMC 명령과 같습니다 – bricelam

답변

1

나는 다음 문서에 의해, 명령 줄 인터페이스를 사용하여이 문제를 과거를 얻을 수 있었다 `말은로드 된거야?
+1

질문과 답변을 공유해 주셔서 감사합니다. – Ehsan