EF connection string as DbContext constructor argument

前端 未结 4 1075
北海茫月
北海茫月 2020-12-19 07:31

I have seen some code sample that put an entity framework connection string as a constructor argument when creating a new DbContext. But when I added a new ADO.NET entity da

4条回答
  •  别那么骄傲
    2020-12-19 07:59

    if you want to change to code first use this :)

        public class MyCustomDBContext : DbContext
        {
            public MyCustomDBContext()
               : base(GetConnectionStringName())
            {
    
            }
    
            public MyCustomDBContext(string connString) : base(connString)
            {
    
            }
    

提交回复
热议问题