Practical Limits to Seed Data

BitLost

Active member
Joined
Dec 10, 2016
Messages
35
Programming Experience
Beginner
Is there a practical limit to the amount of data that can be populated by the seed method?

I have tens of thousands of product lines to add to my database. Put it this way I have one suppliers list in now and this one has 18,000 products. I have another 14 suppliers with varying amounts of products.

I note VS is having a hard time with just this minor list I have added so far.

Is there another way of doing this in this situation? Is there an alternative to seeding for EF? Or is there some other limits I am underwear of?
 
So you are just talking about using an auto-generated primary key in your database. In that case, you can declare it as type 'int' or 'long' in your C# code which translates to 'int' or 'bigint' in SQL Server. That means a 32-bit integer or a 64-bit integer. You can calculate the maximum value for each of those, look them up on the web or use the Help menu to open the MSDN documentation and look up Int32.MaxValue and Int64.MaxValue.
 
So you are just talking about using an auto-generated primary key in your database. In that case, you can declare it as type 'int' or 'long' in your C# code which translates to 'int' or 'bigint' in SQL Server. That means a 32-bit integer or a 64-bit integer. You can calculate the maximum value for each of those, look them up on the web or use the Help menu to open the MSDN documentation and look up Int32.MaxValue and Int64.MaxValue.

Nope. Not what I am asking.

I am asking if there is a limit to how much is practical to include in the seed data? When I add the first supplier product list VS bogged something awful. Simply when I added the records to the seed data method, it went into a Format word and so on loop. This lasted quite a long time computer wise of about 15 minutes before it sorted itself out. What will happen when I paste in the next 30,000?

I am also concurrently asking is it possible to have a separate seed data file? Generally I am wondering if its possible to have a number of them rather than one large one. Thinking it may assist in reducing the overhead on VS.
 
Would you be surprised to learn that I don't really want to read through that whole page you linked to to determine exactly what you mean? It seems that the issue is that loading data into a database using EF is slow. How about you show us exactly what you did so we can see if there's anything wrong with that? There's not much point showing us what you were supposed to do because that would only help if that's exactly what you did.
 
Would you be surprised to learn that I don't really want to read through that whole page you linked to to determine exactly what you mean? It seems that the issue is that loading data into a database using EF is slow. How about you show us exactly what you did so we can see if there's anything wrong with that? There's not much point showing us what you were supposed to do because that would only help if that's exactly what you did.

Don't see how showing you will help its not a code issue. Nonetheless
C#:
Staring at line 2213
new Product { EqTypeID= 16,  ProductCode ="G2RV-SL700 AC240" , ProductDescription="Omron Relay & Base (240vac)" , CostPrice=x.9m , SupplierID=70, CostUpdateDate=DateTime.Parse("30/04/2017") },
new Product { EqTypeID= 16,  ProductCode ="M22N-BC-TRA-RE" , ProductDescription="Omron Pilot light Red c/w LED (240vac)" , CostPrice=x.5m , SupplierID=70, CostUpdateDate=DateTime.Parse("30/04/2017") },
new Product { EqTypeID= 16,  ProductCode ="M22N-BC-TGA-GE" , ProductDescription="Omron Pilot Light Green c/w LED (240vac)" , CostPrice=x.5m , SupplierID=70, CostUpdateDate=DateTime.Parse("30/04/2017") },
new Product { EqTypeID= 16,  ProductCode ="A22NS-2RM-NBA-G100-NN" , ProductDescription="Omron Selector Switch 2 Position Maintained" , CostPrice=x.6m , SupplierID=70, CostUpdateDate=DateTime.Parse("30/04/2017") },
new Product { EqTypeID= 16,  ProductCode ="A22Z-3323" , ProductDescription="Omron Legend Plate (Blank)" , CostPrice=x.8m , SupplierID=70, CostUpdateDate=DateTime.Parse("30/04/2017") },
new Product { EqTypeID= 16,  ProductCode ="A22Z-3443B-10" , ProductDescription="Omron Legend Insert (On-Off)" , CostPrice=x.5m , SupplierID=70, CostUpdateDate=DateTime.Parse("30/04/2017") },
new Product { EqTypeID= 16,  ProductCode ="E5CC-RX2ABM-800, Starter Pack 1" , ProductDescription="Omron Temp Controller, C/W Type K Thermocouple" , CostPrice=xm , SupplierID=70, CostUpdateDate=DateTime.Parse("30/04/2017") },
new Product { EqTypeID= 16,  ProductCode ="F202 25" , ProductDescription="ABB RCCB 2P 25A 30mA   " , CostPrice=xm , SupplierID=70, CostUpdateDate=DateTime.Parse("30/04/2017") },
....
new Product { EqTypeID= 1,  ProductCode ="VP50" , ProductDescription="High Pressure 50L 1600 BAR" , CostPrice=x.25m , SupplierID=35, CostUpdateDate=DateTime.Parse("22/05/2017") },
new Product { EqTypeID= 1,  ProductCode ="VP80" , ProductDescription="High Pressure 80L 1600 BAR" , CostPrice=xm , SupplierID=35, CostUpdateDate=DateTime.Parse("22/05/2017") },
new Product { EqTypeID= 1,  ProductCode ="VP100" , ProductDescription="High Pressure 100L 1600 BAR" , CostPrice=x.5m , SupplierID=35, CostUpdateDate=DateTime.Parse("22/05/2017") },
new Product { EqTypeID= 1,  ProductCode ="VP200" , ProductDescription="High Pressure 200L 1600 BAR" , CostPrice=x.25m , SupplierID=35, CostUpdateDate=DateTime.Parse("22/05/2017") }, 
Ending at line 21279

I have replaced pricing data with X as it is confidential.

Its the sheer quantity that seems to be bogging Visual Studio down. This is why I am asking can I split the initializer code up. I realise this may be a very simple question, but I don't like doing something without checking first.
 
This is why I am asking can I split the initializer code up.
You're simply adding data to a database. Don't applications add data to databases in parts all the time? Presumably there's a call in that code to commit your new data to the database. Despite being asked to show what you're doing, you haven't included that. Presumably you can just put multiple such calls through the initialisation code. You may have to clear the list of data in between if memory usage is an issue. I've never done what you're doing so I'm guessing but there are some obvious logical steps to take that aren't specific to this case.
I realise this may be a very simple question, but I don't like doing something without checking first.
It should be the other way around. Given that you can easily roll back such a change, it should be a case of test first and then you can either ask about a specific issue that occurred or at least show us exactly what you did and ask whether there's a potential issue with it. Either way, you're being specific.
 
Back
Top Bottom