What is the .cs file under MyDataContext.dbml for?

2019-07-03 13:26发布

问题:

What is that individual (currently empty) file under MyDataContext.dbml for?

Directory structure:

Mydatacontext.dbml
    MyDataContext.cs
    MyDataContext.dbml.layout
    MyDataContext.designer.cs

回答1:

It's normally used for you to add a partial MyDataContext class with custom code that won't be overwritten during code generation. If you edited MyDataContext.designer.cs instead, your hand-written code would be erased.