Content
Blazor Server App crashes if DBContext is used
I have a Blazor Server App that runs fine in the VS Web Server but crashes hard when deployed to an IIS 10 Web Server running on a Windows Server 2022 Machine. I have reviewed my use of Entity Framework DBContexts and all are created and disposed very…
how to replace replace IObjectContextAdapter with IInfrastructure<IServiceProvider> using entity framework core 6
Hi Team, since IObjectContextAdapter is not supported by entity framework core 6 please suggest the replacement code which supports the below code - using (var db = new BloggingContext()) { var blogs =…


Error In Update Record (The instance of entity type 'x' cannot be tracked)
I have this error when update record in RoleRepository.cs. i use AsNoTracking but show error again The instance of entity type 'ApplicationRole' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked.…


ASP.NET Core MVC : complex data model reading related data
I am trying to display a drop-down on my DEVICES create.cshtml view of the names from CONTACT via the lookup table DeviceAssignments, below is an ERD. I am already able to display the drops downs for DeviceCategories and DeviceLocations, but I am not…


Turning off cascade deletes
I have a case where I need to turn off cascading deletes (two different models are both wanting to cascade delete and so one needs to be turned off). I think I have this right but I saw numerous different answers all over the place and so want to…


Entity Framework, nullable, and no warnings or hacks
I am trying to get my model constructors written so that nullable works, with no warnings, and no having to assign default! - in other words, to do it all right. BTW, if I'm wrong on any of this, please let me know. I'm mostly there. What's left is…


.NET 6.0 migration issues leads to MySQL stored procedure calling
Once we migrate .NET core 3.1 applications to .NET 6.0, we get below issue while calling MySQL stored procedure, The LINQ expression could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation…


HasDefaultValueSql("getutcdate()").ValueGeneratedOnAdd(); not working as expected
I configure my model as follows: public class CampaignConfiguration : IEntityTypeConfiguration<Campaign> { /// <inheritdoc /> public void Configure(EntityTypeBuilder<Campaign> builder) { builder.HasIndex(new[] {…


How to share Cosmos Document DB Container with Blazor Server App And Cosmos Change Feed Function App using Entity Framework (EF)?
I have a Blazor Server App that uses Entity Framework Core to manipulate my Cosmos Container and I want to incorporate an azure change feed. I have created an Azure Change Feed Function App using the Visual Studio 2022 (Preview). This is configured with…


How write this query in EF Core or Linq
Hello, I want to write this query in linq or lambda EF core SELECT LAG(id) OVER ( ORDER BY ID ) AS PreviousWord ,ID ,LEAD(id) OVER ( ORDER BY ID ) AS NextWord FROM sales Please help


How to save a many to many relationship with Entity Framework
Hi, I have a many to many relationship between Flight and Journey, so I have created an intermediate table to create the relationship: the thing is, I have a list of flights and one Journey, so how can I create the code to make the assembly so I can…


Controller necessary for creating database / Entity Framework
if I create a property set under models and list it in the context class and run a migration and database update the database is not created (as observed through MSSMS). If I create a controller using entity framework in between creating a property set…


EF Core 7.0 with a SQL Table (DB First) having an Identity Column and a Computed Column (Primary Key)
Hi There, I have a fairly simple table in SQL DB as below [dbo].TBL_CUST ColumnCommentsIDInt; Identity (1, 1)D_IDComputed column Calculated as = "DID" + RIGHT('000' + Cast(ID as varchar(3)) , 3) i.e.... Like DID001 / DID019 etc...NameVarchar…


Managing UI CRUD Operations With High Number Of Parent/Child Entities
Hello, I am creating a Knowledge Base application using .Net Core 6, Razor Pages (Non-MVC), Entity Framework Core and SQL Server. I have created a Repository Pattern and am using Unit of Work, in an N-Tier architecture. Each Knowledge Base…


GROUP BY together with ORDER BY MAX in Entity Framework Core using LINQ
Let's assume these 2 classes and corresponding DB tables. public class Ticket { public int Id { get; set; } public string Title { get; set; } public bool IsFinished { get; set; } } public class ReportedTime { public int Id { get; set; } …


EntityFramworkcore.sqlserver installation Problem
EntityFramework.SqlServer can't be isntall ....Getting so many error..


ADO entity data model is missing Visual studio 2022
I have installed entityframeworkcore 7.0.3 but ADO.net data model not show in data template


How should I structure my Entity Framework access/query classes
I've placed all my EF model classes that represent my tables in the Models folder along with my DbContext class - as recomended. I now want to create a class for each table that access the DB using DbContext and the appropriate model class. This is the…


Is there a way to say an entry is unique across 2 column values?
My question is in the context of Entity Frameworks talking to SQL Database. I have a class as follows: public class County { public int Id { get; set; } public string Name { get; set; } public int StateId { get; set; } …


Is Entity Frameworks Core + fluent superior to ADO.NET?
Hi all; I've been fighting Entity Frameworks Core + fluent for about a month now on a new project working to create my model, etc. I have a couple of decades experience using ADO.NET. So I'm comparing the two. Granted, the first project is going to be…

