Why are entity framework entities partial classes?

后端 未结 3 1370
不思量自难忘°
不思量自难忘° 2021-02-07 14:59

I recently began using entity framework, and I noticed that generated entities are partial classes. What are the uses of that? I googled a bit and people mostly speak of validat

3条回答
  •  死守一世寂寞
    2021-02-07 15:34

    For the same reason partial classes typically exist at all, code generation.

    When code is generated; you don't want your additional methods/properties/whatever blown away, so the designers mark such classes partial to allow users to put additional code in a different file.

    In Code-First, the code-generation aspect of EF has largely become obsolete so any EF model classes you create do not need partial.

提交回复
热议问题