I'm using an existing database with the Code First approach.
I will be using all new tables in the DB except one existing table that I need to make use of. I only want to be able to read from this table and not have any changes occur if I call update-database. How will I go about this?
If I use the code like it is below then it gets totally excluded from the context but if I remove the ignore line in OnModelCreating then I have issues with the update-database command as it already exists in the db(and Like I mentioned, I do not want to update this table at any time )
public class DBContext : IdentityDbContext<ApplicationUser>
{
public DBContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public DbSet<person> Persons { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Ignore<person>();
}
public static DBContext Create()
{
return new DBContext();
}
}