Single Connection String with Multiple Entity Framework Models?

后端 未结 3 2188
孤街浪徒
孤街浪徒 2021-02-08 18:33

At work we currently have a very large web application with a connection to a massive database. We have been using Entity Framework for a while now and to make things easier we

3条回答
  •  别那么骄傲
    2021-02-08 18:49

    Add Default Construction in your Class

    public class ItemContext : DbContext
    {
        public DbSetItems get; set; }
        public DbSet ItemDetails { get; set; }
    
        public ItemContext ()
        {
    
            this.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        }
    }
    

提交回复
热议问题