我有一个dbcontext类,我已经初始化了4个dbsets。我的连接字符串是
<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; }
}
当我启用自动迁移时,我收到如下错误
“不支持关键字:'密码:111111; multipleactiveresultsets'。”
有人能说出这个问题吗?
答案 0 :(得分:2)
您的Connection String
格式错误,应该是这样的
connectionString="Data Source=.; initial catalog=someDb; user ID=ab; Password=111111; MultipleActiveResultSets=True;"