-
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. -
Visual Studio 2017 Editor Matters
Some interesting new editor tricks with the latest VS 2017:
The official source of product insight from the Visual Studio Engineering TeamSome of these, I’m not 100% sure I would need to use on a regular bases… But one of certain interest to me is editing on the ragged column. So what do I mean by that?
Basically there are few editors (text, code, etc) and allow one to mark the beginning and ending columns across many rows in a body of text. Being able to do so allows one to globally insert, copy, paste, change the text marked between the start/end selection. This is very useful for visually seeing changes in text across many rows- Yes yes I know most folks would opt to use Find/Replace or Regular expressions- which fine… those have there place. But it is very useful to have a visual select ability as well. The only other place I’ve seen this is in NotePad ++ with it’s column mode editing. Problem is with NotePad++ is that the selection of begin/end has to be within the same columns across consecutive rows. One cannot pick and choose different rows with different begin/end column positions.
Now enter our favorite VS team with Multi-Caret Support… very nice folks! I would only like to see one small change… make the caret locations a little more visible.
-
.Net Conf
Looks like an interesting talk…. I need to find the time to attend.
Join the .NET Conf 2018 free virtual event September 12-14 to learn about the newest developments across the .NET platform, open source, and dev tools. Mark your calendar! -
Time to talk Net Core 3?
Is it time to talk… some good looking things coming for .Net Core 3 – the deeper reach into the UI with added compatibility for Windows Forms and WPF. Have a read….
Are your Windows Forms and WPF applications ready for .NET Core 3.0?
A first-hand look from the .NET engineering teams -
So the begin the long end of Windows 8.1
Has the time come? The Windows “Vista and ME” of modern operating systems finally nearing end of life. Yes, Windows 8.x will soon join the list of… well let us say… “not best operating systems out there” editions.
The only good I ever saw about the Windows 8.x code base was when the Mobile version finally moved windows 7.x mobile forward. Well, that is until Microsoft decided to stop doing mobile. A very sad day when I shutdown my Nokia 1520- It was an excellent phone. Just before I moved my wonderful 1520 to dust shelf of non-supported tech, I was able to get it onto Windows 10 mobile- I even wrote a couple of apps for it. My my…
But I must say, while not the best effort, Windows 8.x did move the OS in new directions. Which needed to happen. My work PC is still a Windows 7 machine (you know that OS that is almost 10 years old)… I’m back in the days with my corporate PC, being reminded how long it took to get past Windows XP… some IT shops are just so slow in moving forward.
The next mission, getting Windows 7 out of my tech life. Windows 10, it’s a keeper… I see as one of the good editions of Windows. And yes, in it’s day…. Windows XP and Windows 7 where great OS’s for their time. But tech has to move forward.
-
Announcing Windows Community Toolkit v4.0 – Windows Developer Blog
The Windows Community Toolkit recently reached over 1 million downloads across all nuget packages. This is a very big milestone for the community and I?m very excited to announce yet another major ?