3

I have a question about programming practices regarding entity framework classes.

When I create the .edmx file, it creates the class, but when I update this file, all methods I made for the this class are gone.

My question is: Should I create another class, that contains all the methods? In this case, the entity framework class would only have attributes?

1
  • Please check my edit, I tried to clean up what you were talking about Commented Aug 28, 2015 at 16:12

1 Answer 1

9

Entity Framework (Model-First) generates a code file for you. Any changes you make to that file will be lost the next time it is generated. There's even a warning to that effect in a comment at the top of the file.

However, those classes are marked partial (as most generated classes are) so you can have a separate code file that contains the remainder of the class definition (ie, your methods). See MSDN for more information on partial classes.

You can also write other classes that take the data objects as parameters. This is usually how you do this, as EF objects are typically left data-only.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.