Adding DbContextOptions in Startup.cs not registering data store

后端 未结 4 1399
陌清茗
陌清茗 2021-01-04 16:58

My problem is that the below code does not register a data store during startup. This is the specific \"error\" statement I get in the response from the application:

4条回答
  •  余生分开走
    2021-01-04 17:36

    EF7 has new sytax from DBContextOptionsBuilder to EntityOptionsBuilder. Following is ready to use for also command line scaffolding.

    public class ContentContext : DbContext
    {
        public DbSet Contents { get; set; }
        public DbSet ContentCategories { get; set; }
    
        protected override void OnConfiguring(EntityOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer("Data:DefaultConnection:ConnectionString");
        }
    }
    

提交回复
热议问题