AddDbContext<TContextService, TContextImplementation> don't use DI to create the db
In my project I have created this DbContext derived class: public class SqliteContext : DbContext, IRepoContext { private readonly string _fullname; public SqliteContext() { _fullname = SqliteHelpers.CreateDbFullName(); } …
Linq Error when migrate entityframeworkcore 2.2 to 3.0
Hello, i am migrating from netcore 2.1 to 3.1. of a solution hosted on Azure. I have encountered many errors due to entityframeworkcore 3. Queries such as DBe.BmsListaInfrastructure.Where (e => e.Amministration == Administration) .ToList (); …
How to pass datatable from c# class to MSSQL Server stored procedure using Entity Framework Core 5.0.1.
I have a data import application written in .Net Framework to migrate to .Net Core. The application uses a c# class to pass a datatable as an input parameter to a MSSQL server stored procedure. The code in EF6 works fine and is pasted below. …
Code first Unique constraint on multiple columns
Say I want a Microsoft SQL Server entity as follows: CREATE TABLE [dbo].[Entity]( [ID] [int] IDENTITY(1,1) NOT NULL, [COL1] [nvarchar] NOT NULL, [COL2] [nvarchar] NULL, [COL3] [nvarchar] NULL, CONSTRAINT [PK_Entity] PRIMARY KEY CLUSTERED Then…
DbContext lifetime in desktop app with SQLite
I am creating a small data-driven desktop application using .NET 5 with WPF, ReactiveUI, Dynamic Data, and EF Core 5. The app uses a local SQLite database to store all persisted state, and relies heavily on dependency injection. I would like to share…
Having trouble with foreign key in entity, can't track because the FK is already part of another object
Scenario: I have an entity that is central to the business, let's call it Company. Entity Foo has FK CompanyID, as does entity Bar. If, within the same context, I retrieve Foo and create an instance of Bar, then try…