Why are Partial Entity Classes Framework?

I recently started using an entity structure, and I noticed that the generated objects are partial classes. What is the use of this? I did a bit of work with Google, and people mostly talk about validation, but I can add confirmation for the generated object as well.

+4
source share
3 answers

For the same reason, classes partialusually exist in general, code generation.

When the code is generated; you don’t need your additional methods / properties / everything that was blown away, so designers mark such classes partialto allow users to add additional code to another file.

Code-First EF , EF, , partial.

+14

partial .

, , , EF, , .

partial , , , , Generation Gap.

+12

By marking it as partial, you can put attributes in this class.
This is convenient, for example, when you need to mark the class generated by DB as Serializableto be able to store it in the Session object (when the SQL server mode is used in balanced environments).

-1
source

Source: https://habr.com/ru/post/1671632/


All Articles