Posts

Showing posts with the label ef core

EF Core

Image
EF Core 5 EF Core 5 does not work with .net framework. It works with .net core 3.0 and above Many to Many Relationships EF core can handle a simple many to many relationship without including a class that represents the associative table. All you need to do is add navigation properties between the two classes that have a many to many relationship. for a more complex many to many relationship, a class will need to be created to represent the associate table. In addition, the OnModelCreating must be updated to define the many to many relationship. Use fluent methods: HasMany, WithMany, and UsingEntity Bulk Operation it will not work when working with less than 4 insertion/update example of increasing and decreasing batch size

dotnet migration from command line

Image
dotnet from command line can do more than just create projects and add packages. It can be used to work with ef core migrations. Lets start by creating a new console app. Run this command:  dotnet new console . Add these three packages: dotnet add package Microsoft.EntityFrameworkCore dotnet add package Microsoft.EntityFrameworkCore.Design dotnet add package Microsoft.EntityFrameworkCore.SqlServer Your csproj should now look like this: <Project Sdk= "Microsoft.NET.Sdk" > <PropertyGroup> <OutputType> Exe </OutputType> <TargetFramework> netcoreapp2.2 </TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include= "Microsoft.EntityFrameworkCore" Version= "2.2.6" /> <PackageReference Include= "Microsoft.EntityFrameworkCore.Design" Version= "2.2.6" /> <PackageReference Include= "Microsoft.EntityFrameworkCore.S...