angelsix / dna-framework

A cross-platform base framework useful for all projects that use .Net Core
MIT License
63 stars 30 forks source link

Use ASP.NET Core 3 #14

Open lorentzfb opened 5 years ago

lorentzfb commented 5 years ago

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?

Vallevard commented 4 years ago

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

xaoseric commented 3 years ago

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

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