简体   繁体   中英

Can't reverse engineer SQL Server database table

I'm trying to create a Web API. I'm following some examples but I can't get anything to work.

The examples say to use this

Scaffold-DbContext connection_string Microsoft.EntityFrameworksCore -OutputDir Models

I don't want to do all the tables so I looks at the "Package Manager Console" help for the command and am told this

-Tables <String[]>
    The tables to generate entity types for.

    Required?                    false
    Position?                    named
    Default value                @()
    Accept pipeline input?       false
    Accept wildcard characters?  false

So I've tried this

Scaffold-DbContext connection_string Microsoft.EntityFrameworksCore -OutputDir Models -Tables dbo.table

I'm changing the names of the connection string and tables. I don't want to do all the tables because there are 70+ tables in this db.

When I try that all I get back is.

"Build Failed"

That's pretty terse so when I stick on -Verbose all I get is

Using project 'ArgusApi'.

Using startup project 'ArgusApi'.

Build started...

Build failed.

A little more verbose, but not much. I was getting more error messages but I cleaned those up to just this.

Any help is much appreciated.

The "Build Failed" message simply means that your project doesnt build. (In Visual Studio) Press F5 and try to build your project. If it cant be built cleanly, then when you run "Scaffold-DbContext" you will get this message.

Usually this happens because your entities/pocos are in some sort of broken state. Delete all your models so they dont break the build and try again.

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