-
From the course: C#: Delegates, Events and Lambdas
https://www.linkedin.com/learning/c-sharp-delegates-events-and-lambdas/welcome
Join Joe Marini for an in-depth discussion in this video, Welcome, part of C#: Delegates, Events and Lambdas. -
From the course: Using Generics in C#
https://www.linkedin.com/learning/using-generics-in-c-sharp/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#. -
From the course: Visual Studio Developer Tips
https://www.linkedin.com/learning/visual-studio-developer-tips/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. -
From the course: Docker for .NET Developers with Visual Studio
https://www.linkedin.com/learning/docker-for-dot-net-developers-with-visual-studio?isLearningSubscriber=true&trk=feed-cymbii_course_title_learning
Discover how to use Docker—a popular software containerization platform—to streamline your .NET development workflow. -
Happy Thanksgiving
Happy Thanksgiving!
-
Azure Deep Dive Class Completed.
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.
-
EF Core adds DB Seeding back with some gotchas
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.
-
Good things coming to EF Core 2.2
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…
A first-hand look from the .NET engineering teams -
From the Dot Net Config some Good Web Sites to check out.
So in the travels about with the .Net Conf this week check out some site:
And…
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…
-
Did you say Free Pipelines?
Who doesn’t like FREE… I may need to have a second like at Azure Pipelines…. on YES!
With the introduction of Azure DevOps today, we?re offering developers a new CI/CD service called Azure Pipelines that enables you to continuously build, test, and deploy to any platform or cloud.