【问题标题】:Keyword not supported error in Enabling migrations启用迁移中的关键字不支持错误
【发布时间】: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


【解决方案1】:

你的Connection String格式不对,应该是这样的

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

【讨论】:

    猜你喜欢
    • 2018-03-18
    • 1970-01-01
    • 1970-01-01
    • 2011-07-18
    • 1970-01-01
    • 2017-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多