How can I prevent the use of the parameterless constructor of the generated DbContext?
var dcx = new DataEntities();
The default constructor is generated by the T4 template, and I thus cannot override it in a partial class. I would prefer it not compile, but a runtime error would also be good.
You can modify the template to provide the constructor you want.
*.Context.tt
fileChange this code.
public <#=code.Escape(container)#>()
: base("name=<#=container.Name#>")
Into the default constructor you want, for example.
public <#=code.Escape(container)#>(string nameOrConnectionString)
: base(nameOrConnectionString)
Save