Keyword not supported error in Enabling migrations

2019-04-15 06:06发布

问题:

I have a dbcontext class where i have initialized 4 dbsets. My connection string is

  <connectionStrings>
    <add name="somename" connectionString="Data Source=.; initial catalog=someDb; user ID=ab; Password:111111; MultipleActiveResultSets=True;"  providerName="System.Data.SqlClient" />
  </connectionStrings>

My dbcotext class is

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; }
    }

When i enable automatic migrations iam getting error as follows

"Keyword not supported: 'password:111111; multipleactiveresultsets'."

Can someone say whats the problem?

回答1:

Your Connection String format is wrong, it should be like this

connectionString="Data Source=.; initial catalog=someDb; user ID=ab; Password=111111; MultipleActiveResultSets=True;"