When I add stored procedures to a linq datacontext, by default visual studio prefixes the stored procedure with the sql schema that it is in. Is there any way to stop this? In our environment, the stored procedures may be moved to other schemas over time, and we will default the schema based on the sql user used to connect. Do I have to do this manually or can I somehow turn off the schema prefixes?
When I add stored procedures to a linq datacontext, by default visual studio prefixes
Share
There doesn’t appear to be any means of removing the schema from LINQ-to-SQL mapped stored procedures using the designer. All procs are mapped including their schema name, which (to be fair) is probably a good thing for most applications. And as with most things LINQ-to-SQL, change your database at your own peril. Too many database changes required LINQ-to-SQL dbml updates & rebuilds.
Digging deeper, the schema name is stored in the backing
dbmlXML file, and is then included in the generateddesigner.csfile which contains the functions / methods which are called.If you manually edit the
dbmlXML file to remove the schema & save within Visual Studio, the code will be regenerated like this:Which worked for my account, logging in with dbo as default schema. I’ll leave the testing up to you.
This might be a workable solution – the visual designer still works like this, other items can be added etc without breaking the schema-less function, and the function itself doesn’t cause the designer to complain. Best of luck!