【发布时间】:2017-08-06 12:45:39
【问题描述】:
我有一个 dbcontext 类,我在其中初始化了 4 个 dbset。我的连接字符串是
<connectionStrings>
<add name="somename" connectionString="Data Source=.; initial catalog=someDb; user ID=ab; Password:111111; MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
我的 dbcotext 类是
public AstroEntities(): base("somename")
{
Database.SetInitializer<AstroEntities>(new CreateDatabaseIfNotExists<AstroEntities>());
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Contact>().ToTable("Contacts");
modelBuilder.Entity<Appointment>().ToTable("Appointments");
modelBuilder.Entity<Consultation>().ToTable("Consultations");
modelBuilder.Entity<HomePageMessage>().ToTable("HomePageMessages");
base.OnModelCreating(modelBuilder);
}
public DbSet<Contact> Contacts { get; set; }
public DbSet<Appointment> Appointments { get; set; }
public DbSet<Consultation> Consultations { get; set; }
public DbSet<HomePageMessage> Homepagemessages { get; set; }
}
当我启用自动迁移时,我收到如下错误
“不支持关键字:'password:111111; multipleactiveresultsets'。”
谁能说说问题出在哪里?
【问题讨论】:
-
你确定
connectionString是正确的吗? -
不正确。密码就像..“密码=”而不是“密码:”..愚蠢的粗心错误。 :D
标签: asp.net-mvc entity-framework entity-framework-migrations