[英]How to use an ApplicationDbContext from another project in a ASP.NET web API project?
I'm trying to make a web API that connects to a server and substracts the information from a data base on that server. 我正在尝试创建一个连接到服务器的Web API,并从该服务器上的数据库中减去信息。
I referenced the models from other project which connects to the same server and the same DB. 我引用了连接到同一服务器和同一个DB的其他项目中的模型。 But when I'm trying to scaffold a model class to get the controller I can't select my ApplicationDbContext who is already on my referenced models.
但是当我试图使用模型类来获取控制器时,我无法选择已经在我引用的模型上的ApplicationDbContext。
I expected the ApplicationDbContext to be shown as an option of Data Context Class. 我希望ApplicationDbContext显示为数据上下文类的选项。
To get an easy solution I made a class where to make the connection and requests to the data base using OleDB class in another class. 为了得到一个简单的解决方案,我创建了一个类,在另一个类中使用OleDB类建立连接和对数据库的请求。
If annyone knows how to do the same but better, I'll appreciate the help. 如果annyone知道如何做同样但更好,我会很感激帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.