简体   繁体   中英

Entity framework invalid column name for static methods

I keep getting an error saying: invalid column 'checked'. This is correct, because i have no column 'checked' in my database model. But i need it for filtering reasoning. Does anyone know how I can keep the checked property, but get rid off the error. I work with Entity Framework

namespace Entities
{
    [MetadataType(typeof(FloorsMetadata))]
    public partial class Floors
    {
        public bool checked { get; set; }
        public static List<Floors> GetFloors(context db)
        {
            return db.Floors.ToList();
        }
    }

    public class FloorsMetadata
    {
        [JsonIgnore]
        public virtual ICollection<Building_Floors>Buildings_Floors { get; set; }
    }
}

namespace Entities
{
    public partial class Floors
    {
        public int id { get; set; }

        [Required]
        [StringLength(100)]
        public string name { get; set; }
    }
}
class StackOverfloContext : DbContext
{
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Floors>().Ignore(p => p.@checked);
    }
}

class Floors
{
    public string name { get; set; }
    public bool @checked { 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