views:

97

answers:

2

At a consulting assignment they are using Subsonic 3.x (latest) which uses the T4 Code Templating Engine (rather than CodeSmith like 2.x did)

When we run it on our DBMS that has ~ 1 thousand tables we run into an error generating the Structs.cs file. T4/Subsonic generates fine on smaller DBs....

An Exception was thrown while running the transformation code. The process cannot continue. The following Exception was thrown:

System.Runtime.Remoting.RemotingException: Object '/f9ce56f8_409c_4465_b81c_5272c8d764dc/dbet1oh1u2djvp2ildubn9nb_25.rem' has been disconnected or does not exist at the server. at Microsoft.VisualStudio.TextTemplating.TransformationRunner.get_Errors() at Microsoft.VisualStudio.TextTemplating.Engine.CompileAndRunCode(String generatorCode, ITextTemplatingEngineHost host, TemplateProcessingSession session) C:\Users\BlahBlahUserName\Documents\Visual Studio 2008\EdsTry\EdSub\ActiveRecord\Structs.tt

This leads to two questions

  1. has anyone seen this and know any workarounds when T4 blows up on large files?

  2. And once I solve that can I modify subsonic so it generates less files (say 1,000 class files rather than 1 large class file)

Vstudio chokes on the large class files it generates if we include the Subsonic generation stiuff in our main project so we do it in separate project and reference the resulting DLL but surely there must be a way to generate several hundred class files from subsonic vs. 1 file with several hundred classes in it.

A: 

your problem is your DB connection timeout, your best best would prob be to work of a local DB server rather than remote so your not waiting for the data alll the time.

also if you look at the TT file you will notice that it gets a list of all tables, loops through them tables and then loops through the fields, the TT file is a file to create a class from template, not to create files and save them somewhere.

but if your database is so massive that you have more than 1000 tables i think you would be better starting at DB design, and maybe splitting the tables into a group of database, and having multiple dals, I.E a product db, a people DB, etc this way you will keep it small and will still be able to use them all if this makes sense

minus4
A: 

I had the same problem and found that this error caused because of connection timeout.

This is how I connect to a database for retrieving of all entities/views/procedures/etc.:

ServerConnection conn = new ServerConnection(serverName, serverLogin, serverPwd);
conn.ConnectTimeout = 0;
conn.StatementTimeout = 0;
Server server = new Server(conn);
Database database = new Database(server, databaseName);
database.Refresh();

// ...

The key moment is to set these two arguments:

conn.ConnectTimeout = 0;
conn.StatementTimeout = 0;

After setting these my generator works well.

Hope it will work for you.

Genius