With code like this:
DataTable schema = conn.GetSchema();
DataTable tables = conn.GetSchema("Tables");
DataTable columns = conn.GetSchema("Columns");
Quite a lot of information can be fetched about the schema, but the metadata version (ie: GetSchema()) doesn't return anything about synonyms.
We use Synonyms quite heavily in our environment. Can I get Schema information about them using GetSchema, or do I need another method?
There is not a schema collection for Synonyms for SQL Server:
SQL Server Schema Collections
There does appear to be a way to override the collections with .NET 3.5. I have never done this though so I don't know if it actually works. The basic idea is that you create an XML file to define how getschema
defines and queries for schema data. You then change your applications configuration to use this XML file to override the collections that are available.
GetSchema Override
There are examples in the provided link to add a Primary Keys collection to the schema. It looks promising if your determined to use getschema
. Otherwise you could create your own schema functions and just query sys.synonyms to get synonyms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With