I know it's old but since I had the same problems and it took me a while to find the solution... I decided to share the info. So I had to do 2 things to get rid of this problem, 1st was disabling the migrations:
# Migrations/Configuration.cs
internal sealed class Configuration : DbMigrationsConfiguration<IntranetApplication.Models.MyDb1>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
}
}
however that wasn't enough, I also had to make sure the Seeder doesn't run. You can cancel it with this extra piece of code:
#Global.asax.cs
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
Database.SetInitializer<Models.MyDb1>(null);
Database.SetInitializer<Models.MyDb2>(null);
...
}
Then finally I can now do a SELECT with LINQ and only have READ access
EDIT
As per Lawrence's suggestion, it's most probably better having it directly inside DB Context Constructor. Thanks for the tip, I updated my code and it now looks like this:
public partial class MyDb1 : DbContext
{
public MyDb1()
: base("name=MyDb1Connection")
{
Database.SetInitializer<Models.MyDb1>(null);
}
...
}