2017-06-02 62 views
0

不知道我應該引用哪個程序集來刪除此阻塞錯誤。錯誤t CS1061 t'DbContextOptionsBuilder'不包含'UseSqlServer'的定義>並且沒有擴展方法'UseSqlServer'

public void ConfigureServices(IServiceCollection services) 
{ 
    // Add framework services. 
    services.AddDbContext<QAContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); 
    // Add framework services. 
    services.AddMvc(); 
} 

錯誤CS1061「DbContextOptionsBuilder」不包含「UseSqlServer」,沒有擴展方法的定義 「UseSqlServer」接受型的 第一個參數「DbContextOptionsBuilder」可以找到(被 你缺少使用指令或程序集 參考)

+0

式搜索'C#CS1061「DbContextOptionsBuilder」不包含「UseSqlServer」,沒有擴展方法「的定義UseSqlServer '接受'DbContextOptionsBuilder'類型的第一個參數可以找到' – MethodMan

+0

['DbContextOptionsBuilder'可能的重複不包含'UseSqlServer'的定義](https://stackoverflow.com/questions/40342137/dbcontextoptionsbuilder-does-not -contain-A-定義換usesqlserver) – Eris

回答

2

如果您正在使用EntityFrameworkCore你必須:?

添加到參考:

Microsoft.EntityFrameworkCore.SqlServer 

添加到源文件:在谷歌以下

using Microsoft.EntityFrameworkCore; 
相關問題