UseSqlServer method missing MVC 6

前端 未结 4 1680
甜味超标
甜味超标 2021-01-03 18:08

I am trying to implement Entity Framework 7 in MVC 6, and on this page here it says to do

services.AddEntityFramework()
    .AddSqlServer()
    .AddDbContext         


        
相关标签:
4条回答
  • 2021-01-03 18:43

    It's a NuGet Packages Problem

    Install the following Packages and with its Proper Versions

     1.  Microsoft.EntityFrameworkCore(Latest Version)
     2.  Microsoft.EntityFrameworkCore.SqlServer(1.0.4 Version)
    
    0 讨论(0)
  • 2021-01-03 18:53

    Install Microsoft.EntityFrameworkCore.SqlServer 1.0.1 package works for me Version of Microsoft.EntityFrameworkCore is 1.1.0

    0 讨论(0)
  • 2021-01-03 18:58

    UseSqlServer is an extension method in the namespace Microsoft.Data.Entity so you need to import that in your code, like this:

    using Microsoft.EntityFrameworkCore;
    
    0 讨论(0)
  • 2021-01-03 19:01

    Since this has been posted, assemblies have been renamed. As part of EntityFrameworkCore you now need to add a using statement the following

    using Microsoft.EntityFrameworkCore;
    

    And the .UseSqlServer extension method to configure your context will become available

    0 讨论(0)
提交回复
热议问题