Sql – How to create a LINQ To SQL datacontext for large DB using SQLMetal when it generates a 12MB DataContext.cs file

linqlinq-to-sqlsqlmetal

My problem is this:

We have a very large Legacy DB with many SPROCs, Views & Tables.

The Designer is a "NO GO" b/c of the size.

I've configured SQL Metal to build the data context, but the resulting code file is so big (12MB) visual studio 2008 will not open it.

If SQLMetal would generate a new file for each class type (Table, View, SPROC_Result), I would be okay.

But as it works currently, I'm hosed.

Ideas??

Best Answer

You could do this:

  1. Run SQLMetal.exe to create the .dbml file.
  2. Create a little script or application to parse the .dbml file (which is XML) into 3 components: tables, stored procedures and views
  3. Run SQLMetal.exe on each of the new .dbml files to create 3 separate .cs files.

In your filter phase (step 2) you could also create other arbitrary divisions of your .dbml file based on other requirements. Perhaps filter out some unnecessary tables or views. Or break the tables into logical components with separate DataContexts.

Related Topic