I'm trying to wrap Entity Framework (6.4.0) around a SQL View (SQL Server) where a couple of columns have spaces in the column names. For example, one column in SQL is "Badge ID", when I wrap EF around this view it renames the column "Badge_ID"
When I try to query, EF throws exception that the data reader is incompatible (makes sense):
System.Data.Entity.Core.EntityCommandExecutionException: The data reader is incompatible with the specified 'Model.vwEmpOrg'. A member of the type, 'Badge_ID' does not have a corresponding column in the data reader with the same name.'
I tried a solution from a code-first approach where in the class definition you can annotate the column name like so:
namespace EXAMPLE.Models
{
using System.ComponentModel.DataAnnotations.Schema;
public partial class vwEmpOrg
{
[Column("Badge ID")]
public string Badge_ID { get; set; }
However the same is exception is still thrown. What am I missing? Why doesn't the annotation on the column name work?