名称为 Nb_delays_90+_ever 的列属性出错(具有特殊字符)

Error with Column attribute with Name Nb_delays_90+_ever ( has special characters )

我有 Code First table class 字段:

   public class NBKI_Response
  {
    [Column("Nb_delays_90+_ever")]
    public int? Nb_delays_90__ever { get; set; }

    [Column("Nb_delays_90+_2y")]
    public int? Nb_delays_90__2y { get; set; }
   }

我在尝试添加新记录时遇到错误 "System.Data.SqlClient.SqlException: Invalid column name"。

为什么以及如何解决?

数据库中列的名称完全相同 "Nb_delays_90+_ever" ...

UPD: 我不允许更改数据库中的列名

UPD2: table 的脚本(我使用现有数据库中的 Code First):

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[NBKI_Response](
[ID] [int] IDENTITY(1,1) NOT NULL,
[External_Data_Id] [int] NULL,
[Total_accounts] [int] NULL,
[Total_negative_accounts] [int] NULL,
[Total_active_accounts] [int] NULL,
[Total_credit_limit] [int] NULL,
[Total_overdue_amount] [int] NULL,
[Total_outstanding_amount] [int] NULL,
[Total_installment_amount] [int] NULL,
[Total_disputed] [int] NULL,
[Total_letigation] [int] NULL,
[Total_bankruptcy] [int] NULL,
[Total_inquiries] [int] NULL,
[Recent_inquiries] [int] NULL,
[Recent_account_date] [datetime] NULL,
[Oldest_account_date] [datetime] NULL,
[Nb_delays_5_30_ever] [int] NULL,
[Nb_delays_30_60_ever] [int] NULL,
[Nb_delays_60_90_ever] [int] NULL,
[Nb_delays_90+_ever] [int] NULL,
[Nb_delays_5_30_2y] [int] NULL,
[Nb_delays_30_60_2y] [int] NULL,
[Nb_delays_60_90_2y] [int] NULL,
[Nb_delays_90+_2y] [int] NULL,
[Own_active_accounts_nb] [int] NULL,
[Max_overdue] [numeric](18, 2) NULL,
[RCC_credit_limit] [numeric](18, 2) NULL,
[rcc_outstanding_amount] [numeric](18, 2) NULL,
[Nb_active_mortgages] [int] NULL,
[Nb_active_microcredits] [int] NULL,
[Total_mortgages] [int] NULL,
[Total_microcredits] [int] NULL,
[Nb_active_consumer_credit] [int] NULL,
[Nb_active_rcc] [int] NULL,
[Total_consumer_credit] [int] NULL,
[Total_rcc] [int] NULL,
[Is_FICO] [bit] NULL,
[Fico_score_v2] [int] NULL,
[Fico_score_v3] [int] NULL,
[Is_SocialLink] [bit] NULL,
[SocialLink] [nvarchar](max) NULL,
CONSTRAINT [PK_NBKI_Response] PRIMARY KEY CLUSTERED 
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, 
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

UPD3 添加跟踪后:

db.Database.Log = m => Console.WriteLine(m);

我看到按列属性的映射不起作用:

INSERT [dbo].[NBKI_Response]([External_Data_Id], [Total_accounts], 
[Total_negative_accounts], [Total_active_accounts], [Total_credit_limit],             
[Total_overdue_amount], [Total_outstanding_amount], 
[Total_installment_amount], [Total_disputed], [Total_letigation], 
[Total_bankruptcy], [Total_inquiries], [Recent_inquiries], 
[Recent_account_date], [Oldest_account_date], [Nb_delays_5_30_ever], 
[Nb_delays_30_60_ever], [Nb_delays_60_90_ever], [Nb_delays_90__ever], 
[Nb_delays_5_30_2y], [Nb_delays_30_60_2y], [Nb_delays_60_90_2y], 
[Nb_delays_90__2y], [Own_active_accounts_nb], [Max_overdue], 
[RCC_credit_limit], [rcc_outstanding_amount], [Nb_active_mortgages], 
[Nb_active_microcredits], [Total_mortgages], [Total_microcredits], 
[Nb_active_consumer_credit], [Nb_active_rcc], [Total_consumer_credit], 
[Total_rcc], [Is_FICO], [Fico_score_v2], [Fico_score_v3], [Is_SocialLink], 
[SocialLink])
VALUES (NULL, @0, @1, @2, @3, @4, NULL, @5, @6, @7, @8, @9, NULL, @10, @11, 
@12, @13, @14, @15, @16, @17, @18, @19, @20, NULL, NULL, NULL, @21, @22, 
NULL, NULL, @23, @24, @25, @26, @27, NULL, @28, NULL, NULL)
SELECT [ID]
FROM [dbo].[NBKI_Response]
WHERE @@ROWCOUNT > 0 AND [ID] = scope_identity()

这不会在 EF 6.1 或 EF Core 2 上为我重现。

using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;

namespace Ef6Test
{


    public class Foo
    {
        public int Id { get; set; }

        [Column("Nb_delays_90+_ever")]
        public int? Nb_delays_90__ever { get; set; }
    }

    public class Db : DbContext
    {
        public DbSet<Foo> Foos { get; set; }


        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);           
        }
    }


    class Program
    {
        static void Main(string[] args)
        {

            Database.SetInitializer(new DropCreateDatabaseAlways<Db>());

            using (var db = new Db())
            {

                db.Database.Log = m => Console.WriteLine(m);
                db.Database.Initialize(true);

                var f = new Foo();
                f.Nb_delays_90__ever = 2;

                db.Foos.Add(f);
                db.SaveChanges();

            }

            Console.WriteLine("Hit any key to exit");
            Console.ReadKey();
        }
    }
}