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

问题描述

问题::"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.

您建议您调试哪些步骤?请检查什么?

 

 



推荐答案

检查所有构造函数.

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()"由于其保护级别而无法访问.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 02:20