user2736022 user2736022 - 1 year ago 361
ASP.NET (C#) Question

UseSqlServer method missing MVC 6

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

.AddDbContext<MusicStoreContext>(options =>

But for me, the
method isnt visible? Anyone know how to make it visible? Or is this an old way of configuring entity framework?

My startup.cs file looks like this

using FluentValidation;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.Framework.ConfigurationModel;
using Microsoft.Framework.DependencyInjection;

namespace me.namespace.project
public class Startup
public static IConfiguration Configuration { get; set; }

public Startup(IHostingEnvironment env)
// Setup configuration sources.
Configuration = new Configuration()

public void ConfigureServices(IServiceCollection services)

// entity framework


Answer Source

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

using Microsoft.Data.Entity;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download