Seeding data in EF Core 2.1

Microsoft announced Entity Framework Core 2.1 RC in Build 2018. Data Seeding probably is one of the most useful features of Entity Framework and it got a nice upgrade on this version. Unlike Entity Framework 6.0, Seeding data is associated with an entity type as part of the model configuration which means Entity Framework can now track added, updated or removed data from one change to another change and generates the corresponding migration script for the changes.

Seeding data in Entity Framework Core now is as easy as:

modelBuilder.Entity<Book>().HasData(new Book {BookId = 1, Title = "Don't read this book"});

Remote debugging websites on Azure App Service (Web App)

Sometimes you need to debug your application in cloud environment (well, I don’t like to say production environment !) to reproduce a bug or test your application against cloud environment data. Azure Web App remote debugging is painless and sweat. The only thing you need is just to attach debugger to your application. To attach debugger, right click on the Web App name and choose Attach debugger from context menu or actions bar:

Attach debugger to Azure Web App
Choose Attach Debugger from context menu or actions bar

Things to remember:

  • When you attach debugger and pause for breakpoint, you stop all requests to your application. Therefore, you should not debug your application in Production environment. Staging environment is one of the best remote debugger friends although.
  • If debugging takes time and app is stopped for a few minutes, Azure treats your website worker process as unresponsive and will try to restart it; Therefore, you need to be quick.