Category "entity-framework"

How to stop EF Core from indexing all foreign keys

As documented in questions like Entity Framework Indexing ALL foreign key columns, EF Core seems to automatically generate an index for every foreign key. This

Entity Framework Database First .Net Core

I have a .Net Standard 2.0 class library project and I want to add Entity Framework to it. I have added the Entity Framework Core package to the project but no

Scaffold-DbContext SQL database Views ? ASP NET CORE 6

I am new to .Net Core and I'd like to know scaffold EF support sql view like it supports sql table in .Net Core 6? If it supports which command will do? For ta

Including One Subitem From A List property while Making use of ThenInclude()

I have a function that's purpose is to pull an auction by its id from the data base and include it's highest bid and the highest bid's type. I was able to get t

'The variable name '@' has already been declared. Variable names must be unique within a query batch or stored procedure.'

string subject= "INSERT INTO Subjects (ThesisNo, [Subject]) VALUES (2, @subject)"; SqlCommand commandSubject = new SqlCommand(subject,con); string temp

How does Entity Framework creates a return model from a stored procedure?

I would like to understand how does EF creates a return model from a stored procedure. I know how to get the return model and even how to customize it but I cou

Add-Migration not adding column to existing table in Entity Framework Core

I am trying to add a new column to my existing table in database, i am specifying new field into class and running Add-Migration command but everytime it is cre

Check if todays date exists in a table with Entity Framework

I have a database table with columns of type dateTime. Now I need to see if there already is a row with today's date, but I don't know how to compare the column

EF LINQ query with Expression: method name expected - How can I pass an Expression into function to be used in EF query?

I have a function that's supposed to return different info from an EF LINQ query based on an Expression and/or lambda that's passed to it. Here's my code: pub

HTTP Patch Delta is Null with oData web service

I am using entity framework code first. My entities and controller were generated by Visual Studio and have not been modified. This issue seems to be that the

How can I avoid TimeOut exception using Entity Framework with a stored procedure?

I'm using Entity Framework to call a stored procedure which takes 2 minutes to execute. As a result, I get a timeout exception. Is there any way I can use my

.NET Core 6/EF Core 6.referencing Microsoft.Data.SqlClient, Version=2.0.20168.4

We've created a Web API using .NET Core 6 and EF Core 6. In development environment all works good but when I do the publish application fails with an error Sy

Multiple using of || and && operands

I have a query using Entity Framework. It has many different operands and I am confused with its priority. I am getting the wrong result. I need all records tha

In my flutter app when i open gps or camera or map , or any url , getting error "Lost connection to device." everytime

I am testing on a real device(Redmi 7A) when I open Camera ,URL,GPS, app always get error "Lost connection to device." but when i test on Samsung m31 or Samsung

A fatal error occurred. The required library libhostfxr.dylib could not be found

I'm working on ASP.NET Project with .NET 5.0. For Database creation, I've run the command dotnet tool install --global dotnet-ef After the installing, when I

Dynamic Search Using Entity Framework

I have a search screen with optional fields using Entity Framework, I want to build a dynamic query without selecting the object and filter on it. I want to Op

Entity Framework Core: load related data after object is queried

It is clear how to query an entity and include all the related data; e.g.: using (var context = new BloggingContext()) { var blogs = context.Blogs .

What is the best way to perform partial updates in EF core and never update certain properties?

I know you can do something like var myObj = _db.MyTable.FirstOrDefault(x=>x.Id==id) and then update myObj property by property that you want to update but i

The instance of entity type cannot be tracked because another instance of this type with the same key is already being tracked

I have a Service Object Update public bool Update(object original, object modified) { var originalClient = (Client)original; var modifiedClient = (Cli

SQL Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

I am using Microsoft.EntityFrameworkCore.SqlServer 2.2.6. I have a stored procedure which typically takes 1 to 2 seconds to execute. I am using .NET Core 2.2 wi