New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UseSqlServer() method is missing from Microsoft.EntityFrameworkCore.SqlServer 1.1.1 #7891

Closed
ChuckkNorris opened this Issue Mar 15, 2017 · 32 comments

Comments

Projects
None yet
@ChuckkNorris

ChuckkNorris commented Mar 15, 2017

While following the Identity4 tutorial, it seems the DbContextOptionsBuilder.UseSqlServer() method is missing. Was this moved to a new package?

error

Exception message: 
'DbContextOptionsBuilder' does not contain a definition for 'UseSqlServer' and no extension method 'UseSqlServer' accepting a first argument of type 'DbContextOptionsBuilder' could be found (are you missing a using directive or an assembly reference?)

Steps to reproduce

services.AddIdentityServer()
                .AddTemporarySigningCredential()
                .AddTestUsers(Config.GetUsers())
                .AddConfigurationStore(builder =>
                    builder.UseSqlServer(connectionString, options => 
                        options.MigrationsAssembly(migrationsAssembly)))
                .AddOperationalStore(builder =>
                    builder.UseSqlServer(connectionString, options =>
                        options.MigrationsAssembly(migrationsAssembly)));

Further technical details

EF Core version: 1.1.1
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10
IDE: Visual Studio 2017

@bricelam

This comment has been minimized.

Member

bricelam commented Mar 15, 2017

Possible external dupe: dotnet/project-system#1741

@ajcvickers

This comment has been minimized.

Member

ajcvickers commented Mar 15, 2017

@ChuckkNorris Does the build fail for you in addition to VS showing the error in the editor window?

@ChuckkNorris

This comment has been minimized.

ChuckkNorris commented Mar 15, 2017

At first, the project did not build and those errors appeared in the Error List. After I restarted Visual Studio, the build no longer failed, but it still stated that the UseSqlServer() extension method could not be found.

@zeeshaniqbal

This comment has been minimized.

zeeshaniqbal commented Mar 17, 2017

remove the follow refs from the csproj file,
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGenerators.Mvc" Version="1.1.0-preview4-final" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration" Version="1.1.0-preview4-final" />
<PackageReferenceInclude="Microsoft.VisualStudio.Web.CodeGeneration"Version="1.1.0-preview4-final" />

Add the following refs,
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0-msbuild3-final" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild3-final" />
Source: https://developercommunity.visualstudio.com/content/problem/10914/scaffolding-net-core-with-entity-framework.html

@ajcvickers

This comment has been minimized.

Member

ajcvickers commented Mar 17, 2017

@zeeshaniqbal We are not entirely sure how this relates to those packages, and they look like older versions as well.

@ghost

This comment has been minimized.

ghost commented Mar 24, 2017

I have this problem also but I do not have the codegeneration in my .csproj file

@ChuckkNorris

This comment has been minimized.

ChuckkNorris commented Mar 24, 2017

@rwobben I don't believe the **.CodeGeneration packages are related to this issue. The issue seems to have resolved itself. Try updating VS2017 (Tools -> Extensions and Updates -> Updates), updating the Microsoft.EntityFrameworkCore.SqlServer package, and restarting Visual Studio.

Update VS2017

@ghost

This comment has been minimized.

ghost commented Mar 24, 2017

Here no updates avaible
I already had version 26228.9

@ChuckkNorris

This comment has been minimized.

ChuckkNorris commented Mar 24, 2017

@rwobben Does your solution build even with the syntax errors?

@ghost

This comment has been minimized.

ghost commented Mar 24, 2017

nope, I will not build.
When building I see the above error
When needed I can put my whole project on github. It's one view and he first steps to make EF work

@ChuckkNorris

This comment has been minimized.

ChuckkNorris commented Mar 24, 2017

Hm - try manually adding the using statement using Microsoft.EntityFrameworkCore; and building again. It could be a Roslyn-related issue.

If you can post it on GitHub, I don't mind checking it out

@olegmusin

This comment has been minimized.

olegmusin commented Mar 24, 2017

Solution builds even with this issue

@ghost

This comment has been minimized.

ghost commented Mar 24, 2017

Thanks, adding the using did solve it

@olegmusin

This comment has been minimized.

olegmusin commented Mar 24, 2017

Anyway it is abnormal

@gersoncardosofilho

This comment has been minimized.

gersoncardosofilho commented Apr 5, 2017

Add using worked for me too, according to this dotnet/project-system#1741, its a bug.

@nukec

This comment has been minimized.

nukec commented Apr 7, 2017

Adding using solved for me as well. Ah ah.

@td4ddk

This comment has been minimized.

td4ddk commented Apr 12, 2017

Adding the using statment solved my problem!

@orassr

This comment has been minimized.

orassr commented May 15, 2017

yep just added it manually

@bradley-varol

This comment has been minimized.

bradley-varol commented May 17, 2017

Okay so adding this manually isn't working for me. It says that the using directive is unnecessary.

Edit: Installing the NuGet package "Microsoft.EntityFrameworkCore.SqlServer" fixed this for me, my bad.
Will leave this comment here for anyone else that makes this (stupid) mistake. Thanks.

@haugan

This comment has been minimized.

haugan commented May 19, 2017

Manually installing the NuGet-package "Microsoft.EntityFrameworkCore.SqlServer" fixed it for me as well -
cheers, @Braed!

@10ARK-LeightonSutton

This comment has been minimized.

10ARK-LeightonSutton commented Jun 23, 2017

Adding the using statement solved my problem too - thanks.

@victorud

This comment has been minimized.

victorud commented Jul 9, 2017

yes, adding using Microsoft.EntityFrameworkCore; solved the problem

Thanks guys..

@flq

This comment has been minimized.

flq commented Jul 28, 2017

Here I am, vs code, did "dotnet new web", have the following packages added via dotnet add package:

<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspnetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" />

Have in Startup.cs using Microsoft.EntityFrameworkCore;

But this line Fails:

public void ConfigureServices(IServiceCollection services)
{
  services.AddMvc();
  services.AddDbContext<ConferenceContext>(b => b.UseSqlServer(""));
}

Startup.cs(20,61): error CS1061: 'DbContextOptionsBuilder' does not contain a definition >for 'UseSqlServer' and no extension method 'UseSqlServer' accepting a first argument of >type 'DbContextOptionsBuilder' could be found (are you missing a using directive or an assembly reference?) [C:\dev\team-system-personal\MVC486\MVC486.csproj]

That is easily the weirdest issue I've seen in a while. So, game over, or what?

@smitpatel

This comment has been minimized.

Contributor

smitpatel commented Jul 28, 2017

Incorrect package

You need reference to Microsoft.EntityFrameworkCore.SqlServer
EFCore is just core package. You need to reference provider specific package.

@flq

This comment has been minimized.

flq commented Jul 28, 2017

Just realized this myself. Now it's here to read as well for the next hapless fool :)

dotnet add package Microsoft.EntityFrameworkCore.SqlServer and off you go

@ruinunes-parkbee

This comment has been minimized.

ruinunes-parkbee commented Oct 6, 2017

It looks like UseSqlServer is now under ConfigureDbContext in AddConfigurationStore.

Code snippet:

services.AddIdentityServer()
 .AddConfigurationStore(opt => opt.ConfigureDbContext = builder => builder.UseSqlServer(AuthorizationConnectionString, options => options.MigrationsAssembly(migrationsAssembly)))
.AddOperationalStore(opt => opt.ConfigureDbContext = builder => builder.UseSqlServer(AuthorizationConnectionString, options => options.MigrationsAssembly(migrationsAssembly)));
@ajcvickers

This comment has been minimized.

Member

ajcvickers commented Oct 6, 2017

@ruinunes-parkbee Nothing has changed here from the EF side. Looks like this is IdentityServer code.

@tiagobarroso

This comment has been minimized.

tiagobarroso commented Nov 9, 2017

I had it when i started with a mvc auth project.
I noticed that it put SQL LITE references into the project and maybe it caused this issue, as a conflict against SQL SERVER.

To fix it i removed all SQL LITE library references, and after that i installed SQL SERVER reference:

dotnet add package Microsoft.EntityFrameworkCore.SqlServer --version 2.0.0

It works for me, i wish that it can be helpful!

@EIDIVANDI

This comment has been minimized.

EIDIVANDI commented Jun 20, 2018

just at the moment had the same problem , after verifing the Msdn link UseSqlServer found that the Microsoft.EntityFrameworkCore has not added the Microsoft.EntityFrameworkCore.SqlServer

@viveksingh30

This comment has been minimized.

viveksingh30 commented Jun 22, 2018

in .proj file change Microsoft.AspNetCore.App to Microsoft.AspNetCore.All


@fragrancewithin

This comment has been minimized.

fragrancewithin commented Jun 30, 2018

I had same issue, to resolve this i had to Install Microsoft.EntityFrameworkCore.SqlServer package separately then use using Microsoft.EntityFrameworkCore.SqlServer;

@manishmawat

This comment has been minimized.

manishmawat commented Oct 9, 2018

Installing Microsoft.EntityFrameworkCore.SqlServer solved the problem for me.
It is strange that the installed package is showing unused in the file, but it is not showing any error now and build is successful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment