I have generated entity model from my database which created entity classes.
1) Is there a way that it creates separate file for each class?
2) Can we move these classes to a different assembly? For example how can I move these classes to a different project in my solution?
I want to separate the entity model from classes and use the classes in Presentation Layer.
You can of course create the
edmxin a separate project but I don’t think you can separate the classes into more than the generated default files. Note that you shouldn’t attempt to edit the generated classes as these will be overwritten when updated and you can easily break stuff too.You can, however, create a
public partial classwith the same namespace and class declaration as each of the Entity objects to allow you to extend the classes and add initialization / validation functions etc. allowing you to put each entity in its own class file for extending.Updated:
All related partial classes must be in the same assembly and need to use the same namespace and class declaration as the original entity
partial classin the<EntityModel>.Designer.cs. See below for example code.