简体   繁体   English

如何在 ASP Net 中搭建一个名称中包含空格的表。 核?

[英]How do I scaffold a table with space in it's name in ASP Net. Core?

I wanna turn my table from already existing database into model using Scaffold-DbContext but the table in question have space in it's name.我想使用Scaffold-DbContext将我的表从现有数据库转换为 model 但有问题的表的名称中有空格。 Let's call this table Supieriors types .我们将此表Supieriors types I've tried doing in like this:我试过这样做:

Scaffold-DbContext "Server=CRM_server;Database=CRMDB;User ID=CRM_access;Password=" Microsoft.EntityFrameworkCore.SqlServer
-OutputDir Models -Tables Supieriors types -Force

and

Scaffold-DbContext "Server=CRM_server;Database=CRMDB;User ID=CRM_access;Password=" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Tables Supieriors_types -Force

After second attempt I didn't get any error massage, just Build failed .第二次尝试后,我没有得到任何错误消息,只是Build failed I'm using -Force flag since I already have 2 other models scaffolded.我正在使用-Force标志,因为我已经搭建了 2 个其他模型。 Also I would like to avoid renaming the table to remove space.另外我想避免重命名表以删除空间。

Did you try putting the table name in the string?您是否尝试将表名放入字符串中? Example: Scaffold-DbContext "Server=CRM_server;Database=CRMDB;User ID=CRM_access;Password=" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -table "[dbo].[Supieriors types]"示例: Scaffold-DbContext "Server=CRM_server;Database=CRMDB;User ID=CRM_access;Password=" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -table "[dbo].[Supieriors types]"

-Tables Supieriors types

Is just not registering correct with the command line parameters, it doesn even reach the Scaffold-DbContext command.只是没有使用命令行参数正确注册,它甚至没有到达Scaffold-DbContext命令。 To make sure the command line knows it's one word, use quotes:要确保命令行知道它是一个单词,请使用引号:

-Tables "Supieriors types"

That said... you will encounter problems everywhere with those table names.也就是说......你会在任何地方遇到这些表名的问题。 You can either find workaround after workaround in every tool you use, or rename the table to something normal once and for all.您可以在使用的每个工具中找到一个又一个的解决方法,或者一劳永逸地将表格重命名为正常的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何替换ASP.Net的MVC4视图以构建div而不是表 - How can I replace ASP.Net's MVC4 View to scaffold out divs instead of tables 如何在ASP.NET MVC 3中创建自己的脚手架模板? - How do I create my own Scaffold Template in ASP.NET MVC 3? 如何覆盖 asp.net mvc 核心中的控制器名称? - How to override Controller's name in asp.net mvc core? 如何使用 ASP.NET 核心和 Html 模式查看每个表格行的完整详细信息 - How do I Watch full details for each table row with ASP.NET Core and Html Modal 当我在Asp.net Core(MVC)中搭建控制器时,出现代码生成错误 - When I scaffold a controller in Asp.net Core (MVC), I get a Code generation error 如何安装 ASP.NET 5 预览模板? 非核心 - How do I install ASP.NET 5 Preview Templates? NOT CORE 如何允许文本框中的图像? ASP.NET核心 - How do I allow images in a textbox | ASP.NET Core 如何更新 Asp.net 核心中的用户声明 - How do I update user claims in Asp.net Core 在ASP.NET Core中支撑现有数据库(Scaffold-DbContext) - Scaffolding existing databases in ASP.NET Core (Scaffold-DbContext) 在asp.net核心Web应用程序2.1中搭建一个管理员CRUD - scaffold an admin CRUD in asp.net core web application 2.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM