Entity Framework 6 set connection string in code

后端 未结 5 990
长发绾君心
长发绾君心 2020-12-25 14:37

I have a dll that uses the Entity Framework 6 to do some database operations. I\'m using a database first approach. The model and everything concerning the Entity Framework,

5条回答
  •  鱼传尺愫
    2020-12-25 14:53

    You can use singleton patter for it . For example

    private YouurDBContext context;
    
        public YouurDBContext Context
        {
            get
            {
                if (context==null)
                {
                    context = new YouurDBContext();
                }
                return context;
    
            }
            set { context = value; }
        }
    

提交回复
热议问题