Snæbjørn
Snæbjørn

Reputation: 10792

Cannot override OnConfiguring in beta5 - no suitable method found to override

After updating EF7 to beta5 from beta4 my OnConfiguring stopped working.

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

I can't figure out what I need to write instead.

Here's my project.json, just in case

{
    "dependencies": {
        "EntityFramework.SqlServer": "7.0.0-beta5",
        "EntityFramework.Commands": "7.0.0-beta5",
        ...
    }
}

it doesn't have "EntityFramework": "7.0.0-beta4" (no beta5 yet). It apparently isn't needed.

DNVM list

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

Upvotes: 0

Views: 3630

Answers (3)

edwardrbaker
edwardrbaker

Reputation: 763

If you are using EF 7.0.0-beta7 the method signature looks thusly:

protected internal virtual void OnConfiguring(DbContextOptions options);

Upvotes: 1

ErikEJ
ErikEJ

Reputation: 41799

You need to use EntityOptionsBuilder in beta 5 (and back to DbContextOptionsBuilder in beta 6)

Upvotes: 2

Snæbjørn
Snæbjørn

Reputation: 10792

Couldn't get OnConfiguring to work.

But now this works

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddEntityFramework()
            .AddSqlServer()
            .AddDbContext<ApplicationDbContext>(opt => opt.UseSqlServer("..."));
    }
}

It didn't in beta4.

NB. Remember to add using Microsoft.Data.Entity;

Upvotes: 1

Related Questions