问题:"DbContext.DbContext()"由于其保护级别而无法访问. [英] PROBLEM: 'DbContext.DbContext()' is inaccessible due to its protection level"

查看:107
本文介绍了问题:"DbContext.DbContext()"由于其保护级别而无法访问.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PROBLEM: 'DbContext.DbContext()' is inaccessible due to its protection level"

(The program was working fine the fields; building name, Address, City where being populated), I don’t think I’ve done anything with the code. I wasn’t working with it for around a month due to other assignments, and then when I’ve opened the project again; it came with these errors.

 

 



推荐答案

DbContext具有各种构造函数.完全没有任何参数的代码将受到保护,这就是为什么您无法从代码中调用它的原因.

DbContext has various constructors. The one with no parameters at all is protected, which is why you can't call it from your code.

检查所有构造函数

Check out all the constructors here.

如您所见,有些构造函数是受保护的,有些是公共的.显然,您将需要调用一个公共对象(例如,您在其中传递连接字符串的构造函数),例如:

As you can see, some of the constructors are protected, some are public. You would obviously need to call one of the public ones (such as the constructor where you pass in a connection string), e.g:

var dbContext = new DbContext(myConnectionString);



这篇关于问题:"DbContext.DbContext()"由于其保护级别而无法访问.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆