Entity Framework | Sequence contains more than one matching element

You have net6.0 target framework which is still not released while you have installed EF6 which is a previous iteration Entity Framework (mainly used with legacy .NET Framework projects) and you also have EF Core (a modern iteration of it) but older version – 5.0 (which you are actually using for your context, see the …

Read more

The EF Core tools version ‘3.1.2’ is older than that of the runtime ‘3.1.7’. Update the tools for the latest features and bug fixes

UPDATE This turned out to be an issue with a lot of facets. Main problem was Visual Studio: https://developercommunity.visualstudio.com/content/problem/438312/vs-2019-preview2-after-saving-edmx-code-is-not-gen.html Please try dotnet tool update –global dotnet-ef and restart Visual Studio

How to implement the field decimal(5,2) in EntityFrameworkCore 1.0 rc2?

I’m seeing some examples like this: entityBuilder.Property(r => r.TotalScore) .HasColumnType(“decimal(5,2)”) .IsRequired(true); and the code to support this is here, so hopefully this is supported in the version you’re using: https://github.com/aspnet/EntityFramework/blob/f416dd9a71a5a6a69715b4ba40a37e6f9da751ef/src/Microsoft.EntityFrameworkCore.Relational/Metadata/Internal/RelationalPropertyBuilderAnnotations.cs

How can I hint the C# 8.0 nullable reference system that a property is initalized using reflection

Whenever you want to tell the compiler “shut up, I know what I’m doing” in regards to nullable reference types, use the ! operator. You can fix your issue by declaring your properties like so: public DbSet<Probe> Probes { get; set; } = null!; public DbSet<ProbeUnitTest> ProbeUnitTests { get; set; } = null!;

How to set command timeout in ASP.NET Core / Entity Framework Core?

If you’re using the DI container to manage the DbContext (i.e. you’re adding the DbContext to the service collection), the command timeout can be specified in the options. In Startup.ConfigureServices: services.AddDbContext<YourDbContext>(options => options.UseSqlServer( this.Configuration.GetConnectionString(“YourConnectionString”), sqlServerOptions => sqlServerOptions.CommandTimeout(60)) );

What app.UseMigrationsEndPoint does in .NET Core Web Application Startup class

This app.UseMigrationsEndPoint() is actually a very handy tool in development. As we develop, we add entities to the db context, or modify ones we have. We run dotnet ef migrations add <NameOfMigration> as usual, and that would generate migration files. I personally would typically run dotnet ef database update when the migrations add command succeeds. …

Read more

EF Core migrations in Docker container

In my opinion, it is your first point (Database.Migrate() due startup) that meets mostly our use case. So for me, it`s currently the preferred way to do that. We have some additional constellations in the starting up process: Docker container locally only (for dev environment and testing for sure) Own startup project which executes the …

Read more