efcore icon indicating copy to clipboard operation
efcore copied to clipboard

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

Open ChuckkNorris opened this issue 9 years ago • 44 comments

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

ChuckkNorris avatar Mar 15 '17 17:03 ChuckkNorris

Possible external dupe: dotnet/roslyn-project-system#1741

bricelam avatar Mar 15 '17 17:03 bricelam

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

ajcvickers avatar Mar 15 '17 19:03 ajcvickers

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.

ChuckkNorris avatar Mar 15 '17 20:03 ChuckkNorris

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

zeeshaniqbal avatar Mar 17 '17 11:03 zeeshaniqbal

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

ajcvickers avatar Mar 17 '17 18:03 ajcvickers

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

ghost avatar Mar 24 '17 19:03 ghost

@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

ChuckkNorris avatar Mar 24 '17 19:03 ChuckkNorris

Here no updates avaible I already had version 26228.9

ghost avatar Mar 24 '17 20:03 ghost

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

ChuckkNorris avatar Mar 24 '17 20:03 ChuckkNorris

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

ghost avatar Mar 24 '17 20:03 ghost

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

ChuckkNorris avatar Mar 24 '17 20:03 ChuckkNorris

Solution builds even with this issue

olegmusin avatar Mar 24 '17 20:03 olegmusin

Thanks, adding the using did solve it

ghost avatar Mar 24 '17 20:03 ghost

Anyway it is abnormal

olegmusin avatar Mar 24 '17 20:03 olegmusin

Add using worked for me too, according to this https://github.com/dotnet/project-system/issues/1741, its a bug.

gersoncardosofilho avatar Apr 05 '17 05:04 gersoncardosofilho

Adding using solved for me as well. Ah ah.

nukec avatar Apr 07 '17 19:04 nukec

Adding the using statment solved my problem!

td4ddk avatar Apr 12 '17 13:04 td4ddk

yep just added it manually

orassr avatar May 15 '17 00:05 orassr

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.

bradley-varol avatar May 17 '17 00:05 bradley-varol

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

haugan avatar May 19 '17 14:05 haugan