'Entity Framework add NOT NULL foreign key

I have this code to in EF to generate my DB using codefirst and fluentAPI

public class PhoneNumber
{
        public int PhoneNumberId { get; set; }
        public string AreaCode { get; set; }
        public string LineNumber { get; set; }
        public PhoneNumberType PhoneNumberType { get; set; }        
        public ICollection<Organization> Organizations { get; set; }
    }

 public class PhoneNumberType
 {
        public int PhoneNumberTypeId { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public ICollection<PhoneNumber> PhoneNumbers { get; set; }
 }

When the db is deployed using migration, the PhoneNumberTypeId in the PhoneNumber table is a FK but the column is null, I want it to force it to NOT NULL. I know I should do it in my dbContext OnModelCreating, but I don't know how.



Solution 1:[1]

I found it, I was missing the property PhoneNumberTypeId in my PhoneNumber class I found the solution here: https://www.yogihosting.com/fluent-api-one-to-many-relationship-entity-framework-core/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 carlosm