gpt4 book ai didi

entity-framework - 使用 F# 配置 EF Core

转载 作者:行者123 更新时间:2023-12-02 03:57:12 26 4
gpt4 key购买 nike

我正在尝试使用 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

这给出了以下编译错误:

没有与方法“AddDbContext”匹配的重载。可用的重载如下所示(或在“错误列表”窗口中)。

我做错了什么?

最佳答案

UseInMemoryDatabase()之后添加|>忽略就可以了:

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

关于entity-framework - 使用 F# 配置 EF Core,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43437037/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com