怎么样:
public partial class MyDatabaseEntities : DbContext { public MyDatabaseEntities(string connectionString) : base(connectionString) { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { throw new UnintentionalCodeFirstException(); } public virtual DbSetMyTable { get; set; }
}
然后像以前一样初始化数据库:
string myConnectionString = "..."; MyDatabaseEntities = new MyDatabaseEntities(myConnectionString);