无法覆盖 beta5 中的 OnConfiguring - 找不到合适的方法来覆盖
Cannot override OnConfiguring in beta5 - no suitable method found to override
将 EF7 从 beta4 更新到 beta5 后,我的 OnConfiguring 停止工作。
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
我不知道我需要写什么。
这是我的project.json,以防万一
{
"dependencies": {
"EntityFramework.SqlServer": "7.0.0-beta5",
"EntityFramework.Commands": "7.0.0-beta5",
...
}
}
它没有 "EntityFramework":“7.0.0-beta4”(还没有 beta5)。显然不需要。
DNVM 列表
Active Version Runtime Architecture Location Alias
------ ------- ------- ------------ -------- -----
1.0.0-beta4 clr x64 C:\Users\Snebjorn\.dnx\runtimes
1.0.0-beta4 clr x86 C:\Users\Snebjorn\.dnx\runtimes
1.0.0-beta4 coreclr x64 C:\Users\Snebjorn\.dnx\runtimes
1.0.0-beta4 coreclr x86 C:\Users\Snebjorn\.dnx\runtimes
* 1.0.0-beta5 clr x86 C:\Users\Snebjorn\.dnx\runtimes default
1.0.0-beta5-12103 clr x86 C:\Users\Snebjorn\.dnx\runtimes
无法使 OnConfiguring
工作。
但现在可以了
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(opt => opt.UseSqlServer("..."));
}
}
在 beta4 中没有。
注意。记得加上using Microsoft.Data.Entity;
您需要在 beta 5 中使用 EntityOptionsBuilder(并在 beta 6 中返回到 DbContextOptionsBuilder)
如果您使用的是 EF 7.0.0-beta7,则方法签名如下所示:
protected internal virtual void OnConfiguring(DbContextOptions options);
将 EF7 从 beta4 更新到 beta5 后,我的 OnConfiguring 停止工作。
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
我不知道我需要写什么。
这是我的project.json,以防万一
{
"dependencies": {
"EntityFramework.SqlServer": "7.0.0-beta5",
"EntityFramework.Commands": "7.0.0-beta5",
...
}
}
它没有 "EntityFramework":“7.0.0-beta4”(还没有 beta5)。显然不需要。
DNVM 列表
Active Version Runtime Architecture Location Alias
------ ------- ------- ------------ -------- -----
1.0.0-beta4 clr x64 C:\Users\Snebjorn\.dnx\runtimes
1.0.0-beta4 clr x86 C:\Users\Snebjorn\.dnx\runtimes
1.0.0-beta4 coreclr x64 C:\Users\Snebjorn\.dnx\runtimes
1.0.0-beta4 coreclr x86 C:\Users\Snebjorn\.dnx\runtimes
* 1.0.0-beta5 clr x86 C:\Users\Snebjorn\.dnx\runtimes default
1.0.0-beta5-12103 clr x86 C:\Users\Snebjorn\.dnx\runtimes
无法使 OnConfiguring
工作。
但现在可以了
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(opt => opt.UseSqlServer("..."));
}
}
在 beta4 中没有。
注意。记得加上using Microsoft.Data.Entity;
您需要在 beta 5 中使用 EntityOptionsBuilder(并在 beta 6 中返回到 DbContextOptionsBuilder)
如果您使用的是 EF 7.0.0-beta7,则方法签名如下所示:
protected internal virtual void OnConfiguring(DbContextOptions options);