[英]Can I import a SQL View from Server Explorer into my Model without having to write the class myself?
I have a SQL View in my server explorer and I need to add its class in my model. 我的服务器浏览器中有一个SQL View ,我需要在模型中添加其类。 I am using the code-first approach.
我正在使用代码优先方法。 I cannot see an option in visual studio that allows me to add the view to the model.
我在Visual Studio中看不到允许我将视图添加到模型的选项。 Do I have to type the class myself?
我必须自己输入课程吗?
If you are using entity framework core there is the command 如果您使用的是实体框架核心,则有以下命令
Scaffold-DbContext "Server=(localdb)\\mssqllocaldb;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -Tables *insert your tables/views here* -OutputDir Models
There is a detailed guide Getting started existing database 有详细的指南入门现有数据库
Hope it helps 希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.