I have used EF many times, but i cant seem to figure out why this is happening.
I have a solution with 2 projects, one is my common library used in a few other applications that has all my entities and one is my updater console application. In the common library i have my context which looks like so.
public class DalContext : DbContext
{
public DalContext() : base(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)
{
Database.SetInitializer(new CreateDatabaseIfNotExists<DalContext>());
}
public DbSet<UserAccount> UserAccounts { get; set; }
public DbSet<GameImport> GameImports { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
then in my console application i go to create an instance of the context, and i get the error
"Object reference not set to an instance of an object".
I am using a basic using statement to create my context so everything gets disposed properly.
using (var db = new DalContext())
{
....
}
i get the error when the using statement is creating the DalContext
object.
both applications are using the same version of EF 6.1.3. I was able to do an add-migration just fine. i dunno, i'm stumped.
I have referenced other applications where i have used this and i cannot find any differences as to why this would be happening. I know its going to be something blatantly obvious.