My code looks like this:
public static void DoSomething(TextWriter log)
{
log.WriteLine("Hey man! I'm running!");
try
{
using (MyDBContext context = new MyDBContext())
{
MemberMaster mm = context.MemberMaster.SingleOrDefault(m => m.MemberMasterId == 1);
if (mm != null)
{
log.WriteLine(string.Format("MemberMasterId = {0}, Username = {1}", mm.MemberMasterId, mm.UserName));
}
else
{
log.WriteLine("Could not find Member with MembermasterId = 1");
}
}
}
catch (Exception ex)
{
log.WriteLine(ex.Message);
}
log.WriteLine("Done!");
}
MyDBContext.cs looks like this:
public class MyDBContext : DbContext
{
public MyDBContext() : this("MyDb")
{
}
public MyDBContext(string connectionName) : base(connectionName) { }
public DbSet<MemberMaster> MemberMaster { get; set; }
}
I've tried to add a modelBuilder to remove Pluralizing names but that simply results in an error about the DB Context having changed....use code first...etc..etc...
Is there a better way to do this? The WebJob is being deployed via AZure with a .ZIP file and resides in the same AppService as my Website.