Response status code does not indicate success: 404

Hi,

I have added DB connection factory

var fac = new OrmLiteConnectionFactory(
                               context.Configuration.GetConnectionString("myCon"),
                                              MySqlDialect.Provider);

            services.AddSingleton<IDbConnectionFactory>(fac);

and added plugin to host

Plugins.Add(new AutoQueryFeature
        {
            MaxLimit = 1000,
            GenerateCrudServices = new GenerateCrudServices { }
        });

But when I try to generate the database first models it doesn’t work:

x csharp https://localhost:44378/ -path D:\mypath\
Response status code does not indicate success: 404 (Not Found).

Versions:

x --version
Version: 6.0.12
ServiceStack: 6.90
Framework: .NET 6.0.18
OS: Microsoft Windows NT 10.0.22621.0

Am I missing a step to generate models from a database?

EDIT: I think I misunderstood docs, I guess this is exporting models after services are setup. I was looking for something like EF DB first where I can generate models from an existing DB

You can generate your model classes but I think you are using the path argument incorrectly. Can you please try the follow command with the GeneratedServices enables for your database like you have in your post configuration.

x csharp https://localhost:5001 -path /crud/all/csharp

The path is referring to the path used on the server, not your local file system. Change the server/port to match how you are hosting your application.

1 Like

Thanks, that worked!

Is there anyway to control generation. For instance only create DTO and not requests or only create Get and not Create requests?

Not from that same endpoint, no, you can use new to help move towards a code-first approach if you are starting with an existing database, and you want AutoQuery services generated for you.

Alternatively, you can also use the IncludeTypes= option on the NativeTypes endpoints (that do the code generation) to have more control over what types/requests are generated. These are focused on generating Request DTOs and related types rather than models, but the paths are predictable, so you could script if you know the requests you want to re-generate for.

Have a look at the API Explorer in this hosted example, you will see the requests it makes in the browser dev tools Network tab to pull the code from the hosted server. Hope that helps.

1 Like