简体   繁体   中英

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. Let's call this table 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 . I'm using -Force flag since I already have 2 other models scaffolded. 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]"

-Tables Supieriors types

Is just not registering correct with the command line parameters, it doesn even reach the Scaffold-DbContext command. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM