views:

123

answers:

4

I would like to use the Entity Framework against a database with well over 50,000 tables. I only want to create entities on a small portion of these tables (less than 10). When I go to add tables using the wizard or server explorer, Visual Studio seems to not be able to handle that large amount of tables. It appears as if the tree view limits out with that many items.

I'm willing to create the mapping manually if that is the only option.

  1. Is there a way to "Filter" the tables to find only the ones I need so I can drag-n-drop?
  2. How do I create an Entity manually and then map it to a physical table?

Note: If LinqToSql would somehow work better for this, I'm open to that as well for this project. I would prefer Entity Framework however.

+4  A: 

What I would do in this case is to create a new database containing just the tables that you want to add from the large database (creating exact copies of course). Use that database to create your edmx file. You now have an edmx file that contains exactly the part of the database you want. Change the connection string and you're ready.

Manually doing this is also possible of course (an edmx file is just xml) but to get the entire conceptual model, physical model and the mapping between them correct will probably take a lot more time.

Ronald Wildenberg
+9  A: 

Try this: create a login in the database which only has access to the 10 tables. Then use that login to connect to the database for the purposes of the designer.

John Saunders
+1 much less work than creating a new database, which is currently the other answer.
Shiraz Bhaiji
that was my first thought as well. I wasn't sure if the server explorer would only show those tables in the list. You may say "why not try it and see" but expanding the table node takes 2 hours (literally) for that many tables in Visual Studio and I'm impatient
Cody C
If it takes more than five minutes, then kill visual studio and say it failed.
John Saunders
This is a great workaround.
Alex James
+1  A: 

Hm I had only bad experience with EF. If it is not a requirement use better NHibernate.

I doubt VS is capable to handle such a big schema. You should create *.edmx file in text editor.

Jenea
Others have had better experiences than you have.
John Saunders
Really interested to see some of the examples.
Jenea
A: 

I know that Linq to SQL supports the use of stored procedures, so in Linq to SQL the answer might be to create views or stored procedures for only the 10 tables that you need, and then drag those into the designer. I would think it would work in a similar manner for EF.

Robert Harvey
This will work, assuming they don't have 500,000 views and 5,000,000 stored procedures.
John Saunders
Oof. Didn't think about that.
Robert Harvey
there are currently 10,000 views I believe. Not many SP's however
Cody C