F
F
FairyFox57002020-02-20 18:03:13
C++ / C#
FairyFox5700, 2020-02-20 18:03:13

Is it possible to add logic to the properties that are used in CodeFirst EF6?

Is it possible to use properties in this way to generate a database in EF6?

private  ICollection<Ingredient> ingredients;
        public virtual ICollection<Ingredient> Ingredients
        {
            get => ingredients ?? (ingredients= new List<Ingredient>());
            set
            {
                if (value == null)
                    throw new ArgumentNullException("Ingredients");
                else if (value.Count() <= 0)
                    throw new ArgumentOutOfRangeException("Ingredients");
                ingredients = value;
            }
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question