Migrating Options to ASPNET Core RC2 - asp.net-core

I have a application built on ASPNET Core RC1, which is using string typed configuration Options, and I am trying to migrate to RC2.
But the following code is not working anymore:
services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));
According to ASPNET Core docs, it was supposed to converted this way:
services.Configure<AppSettings>(Configuration);
But this is also not working. The only overload available for the Configure extensions method accepts only a Action as parameter, and I don't want to have to parse the entire configuration myself.
What would be the right way to migrate this code?

Try adding Microsoft.Extensions.Options.ConfigurationExtensions package.

Related

no option for database templates in new item window

I'm creating asp.net core web application and there'is no database templates in new item window. I've installed "Data storing and processing", "Entity framework 6 tools". I'm actually want to create ADO.net template, but it seems to be I need to install something for any database templates to appeared
ADO.net template is removed in Asp.Net core.And NET Framework, as Entity Framework 6 doesn't support . NET Core.So you should use Entity Framework Core rather than Entity framework in Asp.net core.
If you want to use Entity Framework Core with an Existing Database in Asp.net core,you can refer to the official tutorial.
That looks like normal behavior. In .NET Core you'll need to use Entity Framework Core. If you're trying to reference an existing database, you'll need to scaffold it as they've done away with EDMX models in EF Core. Here's how:
If you don't have it already, install the Microsoft.EntityFrameworkCore.Tools NuGet package and any other EF Core packages you think you might need. For example, if you're developing against SQL Server, install the Microsoft.EntityFrameworkCore.SqlServer package.
Run the scaffolding command in the VS Package Manager Console for the database you're trying to add. Something like the following, although you'll want to read the documentation first to determine the parameters you need:
Scaffold-DbContext 'Data Source=(local);Database=MyDB;Trusted_Connection=True' Microsoft.EntityFrameworkCore.SqlServer
This will create a context class for your database that you can then reference throughout your project.

Is the ASP.NET Core NuGET package Microsoft.AspNetCore.Hosting version 2.2.7 part of ASP.NET Core 5.0?

I am getting a little confused by all the naming and versioning of .NET. I think I understand the whole .NET Framework / Standard / Core thing, but I am now moving into ASP.NET Core territory (I want to give my console application a web interface with Kestrel).
When using the NuGET package manager, I can see the Microsoft.AspNetCore.Hosting package, needed to run the webserver. But the highest available version is 2.2.7.
Question now, is that 2.2.7 part of ASP.NET Core 5.0, or do I have some configuration incorrect that I do not get the latest version for my application?
And if it is indeed part of ASP.NET Core 5.0, where can I find that reference? This table helped me a lot with understanding the core libraries.
I assume you wanna this document which tells about your package :
https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.hosting?view=aspnetcore-5.0
And I think you can focus on those classes or interfaces you'll use and take a look if those are supporting .net 5 by click and refer to the details page. You'll see Applies to at the bottom of each page such as this one.
If I misunderstood in some place which made my post isn't suitable to display here, pls point it out and I'll delete it.

How to create a ASP.NET Core Project in VB.NET language using dotnet cli command?

I have migrated the project from Dot.Net-Framework 4.7.2 to Asp.Net-Core 3.1 with VB.NET language. I have checked in Microsoft link below, there is no CLI Command for VB.NET in Asp.Net Core templates. They mentioned only C# language for ASP.NET Core
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-new
Kindly let me know if there is any way to create a ASP.NET Core Project in "VB.NET"
As far as I know, asp.net core couldn't create the MVC vb.net project. You could use dotnet new --list to see the result:
Besides, according to this github issue, ASP.NET Core Doesn't provide a razor syntax that supports VB.NET.
The workaround is using the custom library like Vazor and ZML to design MVC views and Razor Pages.
More details, you could refer to this github issue.
This question is a bit older, to be sure, but the good news is that today there IS a way to build ASP.NET Core applications in VB.NET.
For the past few days I've been working with Vazor, found here and here. I've found it to be remarkable. It's a very clever solution to a long-standing problem.
The author also has plans to enable Blazor apps in VB.NET projects.

Swashbuckle aspnet core 2.0 Swaggerconfig.cs not created

I'm trying to install Swashbuckle to my web api in aspnet core 2.0. Reading all over google about how to set it up it's written about the SwaggerConfig.cs under the App_Start-folder.
But when I install it never gets created?? Where is it?
All I can do is setting up the basics in Start.cs, and it's just some basics? Where is the SwaggerConfig.cs ?
There are two versions of swashbuckle:
https://github.com/domaindrivendev/Swashbuckle
https://github.com/domaindrivendev/Swashbuckle.AspNetCore
There is no SwaggerConfig file on the AspNetCore version.
Your configuration goes on the Startup.cs:
Swashbuckle.AspNetCore/blob/master/README.md#getting-started

asp.net core project occurs MissingMethodException

I create a new project with ASP.NET Core Web Application(.NET Core).
And it can work after building and running it.
I create a class library with .NET Core and move the files under Service folder in the web project to the library, then add the reference and change namespace in the controllers.
It occurs MissingMethodException after registering a new user.
Asp.net core project seems not able to use class library outside the web project.
The detailed message is as the below.
In ASP.NET Core , everything is in form of nuget packages, hence you might have to create nuget package from the class library and then add it to the current solution.
Hope this information helps.