This way creating a DB is a part of program start, so apart from providing a connection string, there is no need to do anything else to start this app.
Simple, right? With very little work we created a Profiles table with EF Core migrations mechanism. If (context != null & context.Database != null)Īnd as the last instruction in the Configure method, I added: UpgradeDatabase(app) So in Startup class I added: private void UpgradeDatabase(IApplicationBuilder app)
Last missing piece is to run database upgrade at program startup to execute those migrations. I generated a EF Core migration to add a Profiles table to my database. Then with command: dotnet ef migrations add InitMigration Public virtual DbSet Profiles Īnd Profiles class: public partial class Profile Public aspnetcoreContext(DbContextOptions options) Then created an aspnetcoreContext: public partial class aspnetcoreContext : DbContext I added an Entity Framework Core with NuGet packages: This is the page that we will modify later. It will work beautifully, right after you run it. This is a Web Api with React on the front-end. I created an application from a template from Visual Studio.
More examples can be found here (although it is an older version of the convention) – Create a project from a template Selecting only Price and Name of a product.select only those properties, that you need.In this url-based convention you can not only fetch data but also: OData is a convention of building REST-ful interfaces, that define how resources should be exposed and how should be handled. Net Core 3.1 back-end with just a single endpoint serving filtered results. In this post, I’d like to show you a scenario, where OData makes perfect sense.