I'm using EF 4.3 with Ninject. I have a simple DataContext and I've created an interface for it. It's a simple interface:
public interface IMyDataContext
{
DbSet<ComplexType> ComplexTypes { get; set; }
int SaveChanges();
}
Implementation of MyDataContext:
public class MyDataContext : DbContext, IMyDataContext
{
public DbSet<ComplexType> ComplexTypes { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder); //Not sure if this is necessary..
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
And I'm adding it to NInject:
Kernel.Bind<IMyDataContext>().To<MyDataContext>();
Using the connection string name MyDataContext doesn't work and if I use IMyDataContext, it generates another database named the full assembly name. Only one table/class is mapped.. not sure if that has anything to do with it.
<connectionStrings>
<add name="MyDataContext"
connectionString="Server=MyPc\SQLEXPRESS;Database=MyDataContext;Persist Security Info=True;Integrated Security=true;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
I know I can override the constructor on the data context.... but I thought this was supposed to "auto map". Any thoughts?
Thanks in advance!