Category "entity-framework"

How can I create a partitioned table in EF Core?

Let's say I have an object like this: public class ObjectA { public int Id {get;set;} public DateTime CreatedOn {get;set;} ...etc } I want to partitio

EF Core executing previously failed query on SaveChanges

We have a .Net Core 3.1 application which is using EF Core to connect wit the SQL Server database. We are facing one problem, that when an exception occurs in o

EF Core executing previously failed query on SaveChanges

We have a .Net Core 3.1 application which is using EF Core to connect wit the SQL Server database. We are facing one problem, that when an exception occurs in o

How can I use DB first approach in .NET Core 6?

I try to use Entity Framework in a minimal API running in a .NET Core 6 project. As far as I understand I should run dotnet ef dbcontext scaffold xxxx which I d

Can't find single property and navigate related data without IQueryable all properties

I have relational data properties on my objects that I would like to access: public class Person { public ICollection<Address> Addresses { get; private

.NET Core Entity Framework how to map nested class into one sql table

I'm still new to .NET Core. I have this character that I want to store in SQLite using an entity. But by default, Character, CharacterData and CharacterLine are

C# Adding a NOLOCK to a user-defined EF query

I have the following user-defined query: var outerRingEntities = await Databases.OuterRing.Set<TOuterEntity>() .As

The entity type 'Access' requires a primary key to be defined. If you intended to use a keyless entity type call 'HasNoKey()'

i have this ValueObject : public class Access : ValueObject<Access> { public string ControllName { get; set; } public string ActionName { get;

Dotnet 5 scaffold changing table names

I have a database with tables like this: productos parametros before .net5 when I run the Scaffold command dotnet ef dbcontext scaffold "..............." "Pomel

How do I solve SqlNullValueException?

I'm trying to find an entity but I get a SqlNullValueException when entity framework is trying to get the value of a field that's Null. I checked in the databa

How can I query INFORMATION_SCHEMA through Entity Framework?

I'm working on an app that uses metadata db information for analysis purposes, that is, query INFORMATION_SCHEMA and perform tasks based on the data. In order

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