Open RDoser opened 3 months ago
I don't believe this is the correct approach to take. The model validator should still validate property mappings, but it could be easier to override that behavior--this is tracked by #15660.
See also the example of changing the property mapping convention in the docs: Example: Opt-in property mapping
@ajcvickers Thanks. https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-7.0/whatsnew#replacing-an-existing-convention seems to be exactly what I have been looking for for the past month. Not sure why this was so hard to find, but THANK YOU!
@RDoser No. Every property is configured as mapped or not mapped.
Converting a Database First EF6 project to EF Core. The existing database is the arbiter of truth, NOT the POCOs. Model is fully defined using Fluent API and so have removed the
PropertyDiscoveryConvention
inConfigureConventions()
butModelValidator
insists that every read/write property be mapped or tagged withIgnore
or[NotMapped]
attribute. POCOs contain literally thousands of such properties used for functional or front end purposes that have nothing to do with the model/database (for example, hundreds of Flag type enums associated with read/write boolean properties).Only run the
ValidatePropertyMapping(model, logger)
method in ModelValidator ifPropertyDiscoveryConvention
is present in the Model Builder's Conventions collection.