Question

I'm writting a simple t4 template to create scripts for my SQL Server 2008 database. This lines of code:

1 myDataBase.Refresh();
2 var tableName = "sometable";
3 Table t = myDataBase.Tables[tableName];

are resulting in t == null. The "sometable" is in my database and is not mispelled, the connection works fine. Debbuging the template and returning the execution point to the line 3 populates the t variable correctly. Someone can help me to undestand what's happening?

Was it helpful?

Solution

This is a belated response but other developers may find it useful.

 myDataBase.Refresh();
 var tableName = "sometable";
 **myDataBase.Tables.Refresh();**
 Table t = myDataBase.Tables[tableName];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top