Is there an easy way to make an ObjectContext public in debug mode and internal in release mode?
With Linqpad it is very convenient to connect to an ObjectContext for quick testing and querying, so for development purposes I want it to be public. But I don’t want to think of the consequences when the same convenience is deployed to some smart customer.
As mentioned in the comment, this may not be of any practical use, but:
When dealing with a generated
ObjectContextfrom a .edmx file, you’ll need to customize how C# files are generated. The default is not customizable, but the designer has an option “Add Code Generation Item”. If you use this, you’ll get several options. I’m using “ADO.NET Self-Tracking Entity Generator”, but the same way works for all of them. Choosing this adds two template files (Model.tt and Model.Context.tt) to your project, which you are free to modify as you see fit. For the modification you’re asking about, you’ll find<#=Accessibility.ForType(container)#> partial classin theModel.Context.ttfile. You can update this so that it reads