Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore attribute not working #390

Open
Stuart88 opened this issue Sep 3, 2021 · 0 comments
Open

Ignore attribute not working #390

Stuart88 opened this issue Sep 3, 2021 · 0 comments

Comments

@Stuart88
Copy link

Stuart88 commented Sep 3, 2021

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);
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant