0

i would like to know if there is someone that can help me find the best way to manage a db with 50 tables that i assume has to be structured in my mvc application as multiple EMDX files for performance but that will have multiple connection strings that i hate.

So let's make a short example: i have a join of 5 tables to create a customer list grid and another 3 tables join for an employee grid.

I created two edmx context files to manage each grid and i have 2 connection strings.

Now, if i haev to create 30 grid will i have to create 30 edmx files and corresponding 30 connection strings?

The question is: is this the best practice for this? duplicating 30 times the connection string that connects to the same db?

Thanks

Alessio Bacin
  • 71
  • 1
  • 1
  • 10
  • First of all create sql views for your grids - it will make your life much easier. As for the question - one DB = one onnection string. For performance issues (if you'll have them) you can run multiple database queries in parallel (for example http://stackoverflow.com/questions/22928951/running-several-entityframework-database-queries-in-parallel) – Alex Art. Oct 20 '15 at 12:59
  • 50 tables is pretty small for one EDMX file to be honest – JamieD77 Oct 20 '15 at 14:28
  • Sorry ALex, i don't understand how, if i have a hardware performance problem, can solve the problem overloading the cpu eevn more with more tasks to do. – Alessio Bacin Oct 20 '15 at 15:29
  • So Jamie, you think that it's not worth even considering a so small 50 tables db? so you think i won't have problems? won't it depend on the load od the tables? in any case i have performance problems because of old hardware server. Thank you for your answer – Alessio Bacin Oct 20 '15 at 15:32

1 Answers1

1

I am not sure why you need separate connection string. If you are connecting to same database then one connection string is enough.

Also if i understand correctly you are creating separate edmx file for each grid. This is not correct way of using Entity Framework. You should be using only one EDMX file for a database, 50 tables is not a big number. If you have complex query then i'll suggest to use store procedure and call it via Entity Framework using function import

Avinash Jain
  • 7,200
  • 2
  • 26
  • 40
  • The thing is that i create more emdx files cause i need performance cause servers hardware is not at top performance. And have multiple connection strings cause it's asked in the EF6 database first wizard and iif i unflag the creation of the new connection string i don't know how to handle one connection string with 2 edmx files – Alessio Bacin Oct 20 '15 at 15:21
  • I don't see how multiple EDMX actually *improves* performance. However, most of your problems could be solved by simply not using EDMX, but instead, POCOs and a DbContext that you control (Code First, which despite its name *can* be used with existing databases as well). Also, EDMX is deprecated (http://blogs.msdn.com/b/adonet/archive/2014/10/21/ef7-what-does-code-first-only-really-mean.aspx). So, unless you want to end up version locked at EF6 forever, you should be making the move to Code First anyways. – Chris Pratt Oct 20 '15 at 15:52