I have a project that I just started with entityframework6 in code first mode I did my few and generated the tables but when trying to run unit tests entityframework tries to connect locally instead of going to where I'm specifying with my context class attachment info from my web config:
<connectionStrings>
<add name="TMS" connectionString="Password=PWD;Persist Security Info=True;User ID=USERID;Initial Catalog=TMSDB;Data Source=MYIP" providerName="System.Data.SqlClient" />
</connectionStrings>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
Context Miclase:
public class FSContext : DbContext
{
public FSContext() : base("TMS")
{
}
public FSContext(string nameOfConnectionString) : base(nameOfConnectionString)
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Entity<Shipping>().ToTable("FSShippings");
//base.OnModelCreating(modelBuilder);
}
public DbSet<Shipping> Shippings { get; set; }
}
What I'm doing to instantiate it.
FSContext context = new FSContext(“TMS”);