Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq to SQL and large DB model

Tags:

linq-to-sql

First, I am Linq to Sql newbie, so please be gentle :).

I have existing ASP.Net application developed over last 3.5 years. It has pretty big data model underneath, around 350 tables. I am trying to do some new things with Linq to SQL.

First impression is that linq designer and SqlMetal are built for databases not bigger than NorthWind example. Here are some problems I have:

  1. I have table Products that is needed in lots of places (inventory, invoicing, production, ...). If I put table Products in each dbml file, linq designer is going to create Product class in each of them. I don't want that. I want to only one Product class.
  2. I have DataContext about shipping. It needs around 40 tables. This makes dbml file very hard to manage. Is there a way to create smaller dbml files and then include them (as reference) into some "major" dbml?

For now, I really like Linq, but I think it is still seriously lacking design tool for anything bigger than 10 tables.

My solution now is building smaller models with Linq designer and then manually merging them (adding properties and references), so lots of code will be generated, but there will also be lots of manual work.

Did I miss something big or is this current state of affair with Linq to Sql?

like image 321
zendar Avatar asked Nov 08 '08 18:11

zendar


2 Answers

well, my solution was to use SQLMetal's /code option to create plain classes in a .cs file instead of a DBML file, and use partial classes in a separate file to extend the generated ORM classes.

I know that doesn't solve your issue of splitting parts of your database into different ORM assemblies - I just found that without the headache of the DBML / Designer, managing a large number of classes in a .cs file wasn't too bad.

like image 81
James McCormack Avatar answered Sep 30 '22 05:09

James McCormack


Why do you want multiple dbml files? Just stick them all in one. Thats how it's meant to work.

like image 42
GeekyMonkey Avatar answered Sep 30 '22 06:09

GeekyMonkey