V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
edis0n0
V2EX  ›  程序员

Entity Framework Core 如何禁用 10620 警告?

  •  
  •   edis0n0 · 2022-08-11 17:35:03 +08:00 · 802 次点击
    这是一个创建于 616 天前的主题,其中的信息可能已经有所发展或是发生改变。
    ```
    warn: Microsoft.EntityFrameworkCore.Model.Validation[10620]
    The property 'Service.Sources' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
    ```

    每次编译都会输出好几屏这样的警告,虽然写个 comparer 规则就行了,但对这些字段进行比较没有任何意义,不想写。Google 搜了好久也没解决。
    gowk
        1
    gowk  
       2022-08-11 20:31:22 +08:00
    都没什么人回复……
    .NET 好冷清
    但不妨碍它好用:)
    neilq
        2
    neilq  
       2022-08-12 12:17:05 +08:00
    如果是非 vs ide, 在 csproj 里面加进去
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <NoWarn>10620;</NoWarn> (分号分割可以配置多个)
    </PropertyGroup>

    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <NoWarn>10620;</NoWarn>
    </PropertyGroup>

    如果是 vs ,项目右键属性里面能直接改忽略警告
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3640 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:19 · PVG 12:19 · LAX 21:19 · JFK 00:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.