简体   繁体   中英

C# Entity Framework database first symbol in column name

I'm working on a project with a database that has been around for a long time and people aren't too keen on changing anything in it (probably so they won't have to fix their other applications).

The SQL Server database has a column named FORM# but when it gets imported into the C# file, it turns into

public string FORM_ { get; set; }

so I'm getting an error where it says that FORM_ does not exist

I've tried using

[Column("FORM#")]

from System.ComponentModel.DataAnnotations.Schema .

Is there any way to bypass this without making changes to the database name?

See if this works instead of Column("FORM#")

DisplayName("FORM#")    
public string FORM_ { get; set; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM