2017-04-16 161 views
1

我試圖用F#設置EF核心。 我的DbContext看起來像這樣用F#配置EF核心#

type MainContext(options : DbContextOptions<MainContext>) = 
    inherit DbContext(options) 

    [<DefaultValue()>] val mutable dokumenter : DbSet<Dokument> 
    member x.Dokumenter with get() = x.dokumenter and set v = x.dokumenter <- v 

和Startup.fs:

member this.ConfigureServices(services: IServiceCollection) = 
     services.AddDbContext<MainContext>(fun options -> options.UseInMemoryDatabase()) |> ignore 

它提供了以下編譯錯誤:

No overloads match for method 'AddDbContext'. The available overloads are shown below (or in the Error List window).

我在做什麼錯?

回答

1

添加|>忽略後UseInMemoryDatabase()的伎倆:

services.AddDbContext<MainContext>(fun options -> options.UseInMemoryDatabase() |> ignore) |> ignore