简体   繁体   English

是否可以从Server Explorer将SQL视图导入模型中而不必自己编写类?

[英]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.

相关问题 我可以“下载”数据uri,而不必自己做吗? - Can I “download” a data uri without having to do it all myself? 如何从不引用dll的视图中导入模型类 - How do I import model class in view from not reference dll 如何将数据从SQL Server数据集中提取到可以使用的类中? - How can I extract data from my SQL Server Dataset into a class that I can use? 如何在我的视图中访问模型中的属性 - How can I access the attributes from my model in my view 我可以从ASP.net向SQL Server中插入一个大文本值,而不必将整个文件放在Web服务器的内存中吗? - Can I insert a large text value into SQL Server from ASP.net without having the whole file in memory on the webserver? 我可以在没有Form的情况下将模型从视图传递到控制器吗? - Can i pass a Model from view to controller without Form? 如何在没有SecurityException的Silverlight视图模型中为此方法编写单元测试? - How do I write a unit test for this method in my view model in Silverlight without SecurityException? 如何在不“新建” class 实例并自己提供参数的情况下进行依赖注入? - How can I do Dependency Injection without "new'ing" a class instance and providing the parameters myself? 如何从视图中获得双倍到我的 Model? - How can I get a double from the View into My Model? 在asp.net-mvc中,如何从我的视图模型中为html.dropdownlistfor插入类名称 - In asp.net-mvc, How can I insert a class name from my view model for a html.dropdownlistfor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM