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