Entity Framework Core
Entity Framework Core topics
-
EF Migration tasks in the Program.cs – The good and the Ugly
Program.cs of any core project (especially ASP.Net Core) is our first starting point to get some necessary work out of the wrong. In this case EF DB Migrations. You know that EF thing where you keep your attached DB tables in sync with your data models? (or in some cases… mess up your existing database). Life in program.cs normally starts here: public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>(); } But let’s consider this: public class Program { public static async Task Main(string[] args) { IWebHost webHost = CreateWebHostBuilder(args).Build(); // Create a new scope using (var scope…
-
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…
-
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… 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
-
Blazor and EF Core to Nowhere land.
In the long decent into “Experimental” frameworks- this one being Blazor, I’ve been finding some challenges with getting Blazor to work with the latest EF Core. There’s a few examples of Blazor being used with EF Core (i.e. the CRUD example that’s floating around the inter-Tubes), but nothing that seems to work with the latest Blazor Lang template in the latest VS release. One can go to a lower EF Core version, well mostly… I’ve yet to get my Blazor Hosted Core test app to compile…. let alone the DB-Context to Scaffold… it just spews errors no matter which direction I go in… Oh Bother…. I have to remember that…
-
.net Core 2.1 and SQL via EF Core 2.1 -The revisit
Let us Revisit a walk-through using .net Core 2.1 and SQL via EF Core 2.1 to scaffold up data models with an existing Database. New SDK's tend to alter slightly how the tools are used and what one see's.
-
Build 2018 Session: Entity Framework Core 2.1: Simple, Powerful Data Access for .NET
Entity Framework Core 2.1: Simple, Powerful Data Access for .NET Entity Framework Core 2.1: Simple, Powerful Data Access for .NET : Build 2018 We know the data tier is one of the most important parts of your application. That’s why we’ve worked hard on the latest release of Entity Framework Core 2.1… Source: On YouTube
-
.net Core 2.0 and SQL via EF Core 2.0
So I can never remember the order that these goes in so Here we go: A console App with .net Core/SQL Server/EF Core 2.0 – In VS 2017 – Create a in .Net Core a Console App (.NET CORE) -Package Manager Console: Install-Package Microsoft.EntityFrameworkCore.SqlServer [Current Version was 2.0.1] Install-Package Microsoft.EntityFrameworkCore.Tools [Current Version was 2.0.1] Install-Package Microsoft.EntityFrameworkCore.SqlServer.Design [Not sure this one is required] Now let’s say we have a database and table…. Let’s reverse engineer it! Scaffold-DbContext “<that magic connect string>” Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models This is command that will use the <that magic connect string> and the provider Microsoft.EntityFrameworkCore.SqlServer with the code generation going into the Models sub-directory. Examples <that magic connect string>…



