我正在try 在MVC6中实现实体框架7,在这一页上,它说要做here
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<MusicStoreContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
但对我来说,UseSqlServer
方法是不可见的?有人知道如何让它可见吗?或者这是配置实体框架的旧方法?
我的startup.cs
文件是这样的
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()
.AddJsonFile("config.json")
.AddEnvironmentVariables();
}
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
// entity framework
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<DataContext>();
}
}
}