How to disable automapping of properties in Entity Framework

一个人想着一个人 提交于 2019-12-01 21:32:17

So far as I am aware, there is no other way around it. You need to use either Ignore() or [NotMapped]. I tend to prefer the former as it does not clutter up the model.

Actually I have tried a lot of ways: - custom convention to remove mapped properties - removing all conventions

But the easiest (and cleanest) way was to use reflection inside the mapping class and to disable all property mappings that weren't configured.

The code for that (and also an usage example) is inside my public gist. https://gist.github.com/hidegh/36d92380c720804dee043fde8a863ecb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!