EF Reverse Engineering can't handle " #" in column name.

Bill Duffy 0 Reputation points
2023-12-11T05:44:34.2966667+00:00

I have a database that uses two different fields:

string "Asset
int "Asset #"

After running EF Reverse Engineering on the existing database, it creates a model with:

        [Column("Asset")]
        public string Asset { get; set; }
        [Column("Asset #")]
        public int Asset { get; set; }

This causes compile errors and fails to build. In this case I am running a secondary script that edits the resulting files and changes "int Asset" to "int AssetNum", which is a hack at best.

Is there another method within EF I can use to fix this?

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
779 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.