dna-framework icon indicating copy to clipboard operation
dna-framework copied to clipboard

Use ASP.NET Core 3

Open lorentzfb opened this issue 5 years ago • 2 comments

I've updated my server project to ASP.NET Core 3 and have tried to implement Dna.Framework.AspNet. I've followed this guide and made the following changes related to Dna:

Program.cs

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseDnaFramework(construct =>
                    {
                        // Add file logger
                        construct.AddFileLogger();
                    });

                    webBuilder.UseStartup<Startup>();
                });

It builds and runs, but the DI shortcuts don't work (ie. DI.ApplicationDbContext) and throws System.InvalidOperationException: 'Cannot resolve scoped service 'xxx.ApplicationDbContext' from root provider.'

Any ideas?

lorentzfb avatar Oct 12 '19 09:10 lorentzfb

@lorentzfb Hi, Did you find a solution for this problem?

Vallevard avatar Aug 12 '20 18:08 Vallevard

For 3.0 and up, you need to use the IApplicationBuilder.

public void Configure(IApplicationBuilder app) { app.UseDnaFramework() }

xaoseric avatar Mar 11 '21 19:03 xaoseric