Looking for approach for DB access with EF 6. i am using .net MVC 5 and i have this code:
public IEnumerable<string> GetSPSites()
{
List<string> spSites = new List<string>();
using (var context = new DevPortalDBContext())
{
var sites = context.Spsites;
foreach(var item in sites)
{
spSites.Add(item.Url);
}
}
return spSites;
}
But i guess this approach for accessing the db every time is not so good. i would like to know if there is a better way or something like dependency injection that i can do in the constructor. please let me know, Thank you ! (* new to .Net *)
my assumption is that 100 users will use this code at parallels.