Entity Framework - .cs files are getting deleted under .tt file


I am working in Entity framework version version 6.0.

When ever I do "update model from database" on entity designer, it removes all .cs file under the .tt files. It is hard
to get them back. These cs files are named by the database table names.

Can someone help me how can I prevent all .cs files from being deleted under .tt file?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
That is by design. If you look at the top of those files the warn about this. Are you modifying these files and losing your modifications? If so you need to make these modification in another file with the same class name, A partial class, which at compile time gets combined with the class created by entity framework.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fernando SotoRetiredCommented:
If this is not the case please tell us why you want to stop this functionality?
Prakash SamariyaIT ProfessionalCommented:
It is default feature of EF, as if we change in a table in a database, we don’t have to find and change the name of the corresponding C# class. Instead, we can re-execute the template and regenerate the class definitions.  And it should work automatically when you save your EF model and Build your project!

Either you can also force a template to generate class by right clicking on a template [.tt] and selecting “Run Custom Tool” from the context menu.
r_pat72Author Commented:
Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.