I have this in a DAL:
public bool MyProp { get; set; }
My intention is to remove that property from the db, and calculate it at runtime instead, so I've modified it like this:
[NotMapped]
public bool MyProp => Smthng > Something.Else;
However, when I run Add-Migration -ProjectName Api.My.DAL MyClass.MyProp
from the Package Manager Console, I get this error:
The property 'MyProp' is not a declared property on type 'MyClass'. Verify that the property has not been explicitly excluded from the model by using the Ignore method or NotMappedAttribute data annotation. Make sure that it is a valid primitive property.
It's asking me to ensure I'm not using NotMapped
, but I want to. And even if I remove it, the error stays exactly the same. So I no longer know what to look for.
Disclaimer: I already searched on Google. Plenty of results, all for problems completely different from this one. If there is something out there, it's well hidden from me.
I'm using EF6 on VS 2019 on a .NET Framework 4.7 project.
There was an additional check in a Configuration
file:
Property(smwh => smwh.MyProp).IsRequired();
Removing this did the trick.