oysteinkrog / SQLite.Net-PCL

Simple, powerful, cross-platform SQLite client and ORM - Updated version with PCL support
MIT License
353 stars 162 forks source link

Ignore attribute not working #390

Open Stuart88 opened 3 years ago

Stuart88 commented 3 years ago

This is on the latest stable version of the library (1.8.116)

I'm not sure if this is a bug or by design.

The ignored 'Number' column in the below class is being added to the table upon creation of the database.

      [Table("Questions")]
      public class Question
      {
        [PrimaryKey, AutoIncrement]
        public int Id { get; set; }

        [Unique, NotNull]
        public string UrlCode { get; set; }

        [NotNull]
        public string QuestionText { get; set; }

        [NotNull]
        public string QuestionAnswer  { get; set; }

        [Ignore]
        public int Number { get; set; } = 1;

     }

Current workaround is to ignore the column in OnModelCreating instead:

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Question>().Ignore(q => q.Number);
        }