DNX版本是dnx-coreclr-linux-x64.1.0.0-rc1-15838。
EF版本是7.0.0-rc1。
Startup.cs中ConfigureServices方法的代码如下:
public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddEntityFramework() .AddSqlServer() .AddDbContext<EfDbContext>(options => { options.UseSqlServer(Configuration.Get("Data:ConnectionString")); }); }
运行dnx kestrel时出现如下的错误:
error CS1061: 'EntityFrameworkServicesBuilder' does not contain a definition for 'AddSqlServer' and no extension method 'AddSqlServer' accepting a first argument of type 'EntityFrameworkServicesBuilder' could be found (are you missing a using directive or an assembly reference?)
请问如何解决这个问题?
by renaming EntityFramework.SQLServer to EntityFramework.MicrosoftSQLServer
果然是改名惹的祸,在project.json中将
"EntityFramework.SqlServer": "7.0.0-*"
改为
"EntityFramework.MicrosoftSqlServer": "7.0.0-*"
之后,问题解决。