Caching of database schema in CodeSmith

by Miha Markič 5. February 2006 21:40

So you've build a template (or using one) for CodeSmith that uses SchemaExplorer.DatabaseSchema class - the one that enables you browsing through database schema with ease (through a nice API) and a killer feature when dealing with databases. There is one catch though:

The first time you run a template it takes a little longer to execute while the next time (if you didn't change it in between). The reasons for this behaviour are two:

  • CodeSmith Professional does template code caching (it compiles the template only once if not closed or changed). This is good for batching - it saves you time.
  • Perhaps less know is the fact that it does caching of database schema, too.

The later fact might be a problem. Imagine you run a template that does database modifications (creates a SQL that you run). Now, the second run will produce the exact same script not taking in account that database was meanwhile changed. Don't worry though as solution is simple. Just invoke this method somewhere at the beginning of the template code and you are fine:

[your instance of DatabaseSchema].Refresh();

Tags:

.net

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Miha Markic

About me
Righthand
 
Microsoft MVP
 
Developer Express' DXSquad
INETA Country Leader for Slovenia
INETA Country Leader for Slovenia

Slovene Developer Users Group Lead
Friends of Red-Gate
LLBLGenPro Partner

Miha currently works as a free lance consultant and software developer specialized in .net area.
He graduated in Computer and information science at the University of Ljubljana, Slovenia. He has accumulated experience in various programming languages such as Java, Visual Basic 3-6 (MCP), Visual C++, Delphi, C# and VB.Net through years.
He has experience in practically all (technical) stages of project development, including planning, framework development, user interface, business processes, as well as testing and documenting. He has worked on big and small projects in Slovenia and abroad (e.g. participated in completing level 3 IS for the Nucor steel plant, Hertford, USA).
Currently he enjoys programming in .net environment using C#. Since 2000 he has been active in Developer Express' DX Squad and has been ECDL trainer and tester. He also gives lectures on conferences and other events in Slovenia.

Month List

Tag cloud

Most comments

Paulius Paulius
1 comments
us United States
Meh Meh
1 comments
us United States
bart dm bart dm
1 comments
nl Netherlands

RecentComments

Comment RSS