• 请不要在回答技术问题时复制粘贴 AI 生成的内容
edis0n0
V2EX  ›  程序员

Entity Framework Core 如何禁用 10620 警告?

  •  
  •   edis0n0 · Aug 11, 2022 · 1769 views
    This topic created in 1395 days ago, the information mentioned may be changed or developed.
    ```
    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  
       Aug 11, 2022
    都没什么人回复……
    .NET 好冷清
    但不妨碍它好用:)
    neilq
        2
    neilq  
       Aug 12, 2022
    如果是非 vs ide, 在 csproj 里面加进去
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <NoWarn>10620;</NoWarn> (分号分割可以配置多个)
    </PropertyGroup>

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

    如果是 vs ,项目右键属性里面能直接改忽略警告
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2879 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 09:05 · PVG 17:05 · LAX 02:05 · JFK 05:05
    ♥ Do have faith in what you're doing.