EF 4.1: Do I need to add DbSet properties to DbContext?
I'm primarily using the DbContext.Set<>()
method to get a DbSet
for a given entity, and I'm not using any of the DbSet auto-properties on my specialized DbContext class.
Do I actually need to have any of these auto-properties defined if I'm not using them directly? Or are they required by the EF 4.1 Code First infrastructure?
Ideally I would like to get rid of them, because they are just a maintenance headache.
We're using开发者_Python百科 Fluent mappings with no database initialization strategy, if that helps.
They are not required if you are using fluent mapping. They are "required" only if the mapping is defined with default conventions or data annotations because in such case it is the only way how EF infrastructure can be informed about classes which must be mapped.
They are not must have properties. They improve the readability if you are using Query comprehension syntax
.
We are also using the DbContext.Set<>()
method and haven't had problems with that.
精彩评论