0

I have to write an application which is creates/updates/deletes database entries. This part I've done, however I must also implement a function that returns the current size of the database in KB/MB which I'm having bigger problems with.

Basically I'm doing Code First, so I created the model class and the DBContext class for it which returns value I need.

Is there a way for, let's say a DBSet, to somehow get the size of my DB entries in KB/MB? I've googled to find if maybe there are some other helpful classes for this but no luck.

ab1428x
  • 794
  • 2
  • 8
  • 20
  • Are you using LocalDB or an external SQL Server to host the resulting database? Additionally, if using LocalDB, are you attaching it as a file? – CodingIntrigue Jan 08 '14 at 11:54
  • For testing purposes I'm using LocalDB now however I will be imigrating to to an external server. The result must by set by code – ab1428x Jan 08 '14 at 12:02
  • 3
    Work out how to get the size using raw sql http://stackoverflow.com/questions/18014392/select-sql-server-database-size then run raw sql using DbContext http://msdn.microsoft.com/en-gb/data/jj592907.aspx – Colin Jan 08 '14 at 12:05
  • Thanks! I'll definitely try using this – ab1428x Jan 08 '14 at 12:08

0 Answers0