• Home Page

ScottGeek Tech

On a Mission to Civilize

  • Home
  • Microsoft
    • Build2018
    • ASP.NET Core
    • .Net Core
    • REST
  • Home
  • Microsoft
    • Build2018
    • ASP.NET Core
    • .Net Core
    • REST

Site Topic Index

  • Article,  Microsoft

    Azure: Static Web Pages Article

    December 21, 2018 / No Comments

    I’m not really into “Static” web pages, but an interesting read popped up on the Azure Blog.

    Static websites on Azure Storage now generally available
    Static websites on Azure Storage now generally available
    Today we are excited to announce the general availability of static websites on Azure Storage, which is now available in all public cloud regions.
    azure.microsoft.com

     

    Read Full Post
  • Free Courses

    From the course: C#: Delegates, Events and Lambdas

    November 23, 2018 / No Comments

    https://www.linkedin.com/learning/c-sharp-delegates-events-and-lambdas/welcome

    C#: Delegates, Events and Lambdas - Welcome
    C#: Delegates, Events and Lambdas – Welcome
    Join Joe Marini for an in-depth discussion in this video, Welcome, part of C#: Delegates, Events and Lambdas.
    www.linkedin.com

     

    Read Full Post
  • Free Courses

    From the course: Using Generics in C#

    November 23, 2018 / No Comments

    https://www.linkedin.com/learning/using-generics-in-c-sharp/using-generics-to-make-your-code-safer-and-more-valuable

    Using generics to make your code safer and more valuable
    Using generics to make your code safer and more valuable
    Join Robby Millsap for an in-depth discussion in this video, Using generics to make your code safer and more valuable, part of Using Generics in C#.
    www.linkedin.com

     

    Read Full Post
  • Free Courses

    From the course: Visual Studio Developer Tips

    November 23, 2018 / No Comments

    https://www.linkedin.com/learning/visual-studio-developer-tips/the-clear-recent-project-list-extension

    The Clear Recent Project List extension
    The Clear Recent Project List extension
    Join Walt Ritscher for an in-depth discussion in this video, The Clear Recent Project List extension, part of Visual Studio Developer Tips.
    www.linkedin.com

     

    Read Full Post
  • Free Courses

    From the course: Docker for .NET Developers with Visual Studio

    November 23, 2018 / No Comments

    https://www.linkedin.com/learning/docker-for-dot-net-developers-with-visual-studio?isLearningSubscriber=true&trk=feed-cymbii_course_title_learning

    Docker for .NET Developers with Visual Studio
    Docker for .NET Developers with Visual Studio
    Discover how to use Docker—a popular software containerization platform—to streamline your .NET development workflow.
    www.linkedin.com

     

    Read Full Post
  • Uncategorized

    Happy Thanksgiving

    November 22, 2018 / No Comments

    Happy Thanksgiving!

    Read Full Post
  • Microsoft

    Azure Deep Dive Class Completed.

    November 8, 2018 / No Comments

    Finished up a week of deep dive into Azure Logic Apps, Service Bus, and Integration accounts.

    I need to write up some conversations…. and of course, some setup walk-throughs.

    Read Full Post
  • Microsoft

    EF Core adds DB Seeding back with some gotchas

    October 10, 2018 / No Comments

    Looking back down the latest with EF core (in my case 2.1.4), I notice some gotchas when it comes to Data Seeding….

    So basically when you involve your migrations with using .HasData it’s understood that you must provide a initial value for all columns that are keys.
      **Side note: this comes from the EF Core team that they want to maintain consistency across multiple migrations. Well, I can understand their reasoning, but I think it’s unnecessary, because we are talking about in most cases initial testing data. I get it.

    With this requirement in mind, this brings up some problems with seeding. In particular with data classes that have constructors and entities with private setters. Consider the example (taken from a PluralSight course on this very topic):

    public class Location
    {
        public int LocationId { get; private set; }
        public string StreetAddress { get; set; }
        public string OpenTime { get; set; }
        public string CloseTime { get; set; }
        public List<Unit> BrewingUnits { get; set; }
        public Location(string streetAddress, string openTime, string closeTime)
        {
            StreetAddress = streetAddress;
            OpenTime = openTime;
            CloseTime = closeTime;
        }
    }

    For locationId we have a private setter, because this will be handled on the DB as Id type key. Well when it comes to doing a DataSeed:

    modelBuilder.Entity<Location>().HasData(
     new Location
      {
            LocationId = 1,
            StreetAddress = "1 Main Street",
            OpenTime = "6AM",
           CloseTime = "4PM"
        });

    This code is going to have a problem, because for New Location, the private setter will throw a compiler error, yeap. But EF Core HasData must be able to set ALL key values. Yeah, how to paint oneself into a corner.

    Well, anonymous types to the rescue!

    modelBuilder.Entity<Location>().HasData(
     new {
          LocationId = 1,
          StreetAddress = "1 Main Street",
          OpenTime = "6AM",
          CloseTime = "4PM"
         });

    It becomes anonymous because Location type is removed from the new statement- the Location type is already known because of .Entity of Location type- so EF Core already knows how to build the migration.

    If we look at the actual migration code:

    migrationBuilder.InsertData(
     table: "Locations",
      columns: new[] { "LocationId", "CloseTime", "OpenTime", "StreetAddress" },
               values: new object[] { 1, "4PM", "6AM", "1 Main Street" });

    We see the key is getting set- that will make EF Core happy.

    Is this a good or bad way to deal with this? It depends on your take on anonymous types. It does feel a little kluge like. But again, this comes from how the EF Core team decided to handle HasData seeding when it comes to keys. Btw, foreign keys are not excluded from this requirement. 

    Read Full Post
  • CosmosDB,  Microsoft

    Good things coming to EF Core 2.2

    September 17, 2018 / No Comments

    I noticed some interesting matters coming to the EF Core. Having access to additional Databases, what’s not to like about that? From the check it department… 

    Announcing Entity Framework Core 2.2 Preview 2 and the preview of the Cosmos DB provider and spatial extensions for EF Core
    A first-hand look from the .NET engineering teams
    blogs.msdn.microsoft.com

     

    Read Full Post
  • .Net,  Microsoft

    From the Dot Net Config some Good Web Sites to check out.

    September 13, 2018 / No Comments

    So in the travels about with the .Net Conf this week check out some site:

     

    Discover .NET
    Discover .NET
    Awesome .NET open source & community resources
    discoverdot.net

     And…

    Showcase of projects built with .net technology - BuiltWithDot.Net
    Showcase of projects built with .net technology – BuiltWithDot.Net
    BuiltWithDot.Net is a community showcase of projects built with .net framework, .net core, xamarin, mono, mono game, unity, or godot. Anyone can submit.
     

    And… 

    .NET Foundation
    dotnetfoundation.org

     

    Read Full Post
Load More

The Cloud of Things

.Net • .Net Core • .Net Core 3.0 • .NET Framework • Article • ASP.NET Core • Azure • BizTalk • Build • Chrome • Cloud • Community Stand up Links • Community Toolkit • Containers • Core • CosmosDB • Docker • Entity Framework Core • FlipBoard • Free Courses • GitHub • IIS • Live Drawing • Mobile • Phone Posts • Photo Tech • Pinterest • Proxmox • Raspberry PI • REST • REST API • Security • Site News • SQL Server • Twitter • UWP • Visual Studio • Visual Studio 2017 • Visual Studio 2019 • WatchMaker • Windows 10 • WSL • Xamarin

Archives

Privacy Policy         ScottGeek - © 2025 All Rights Resevered