使用F#配置EF Core

时间:2017-04-16 12:03:50

标签: entity-framework f# asp.net-core

我试图用F#设置EF Core。 我的DbContext看起来像这样

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 个答案:

答案 0 :(得分:1)

|>之后添加UseInMemoryDatabase()忽略诀窍:

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