Most voted "entity-framework-core" questions
The Entity Framework (EF) Core is an open source cross-platform ORM developed by Microsoft. DO NOT use this tag for Entity-Framework questions, in which case use the [Entity-framework].
Learn more…150 questions
Sort by count of
-
9
votes2
answers995
viewsLazy Loading EF Core, upload daughter entities and daughters?
I have a Web Api I’m developing using the DotNet Core and EF Cor but is with the Lazy Loading active, only that in some cases I need to load the entities daughters and daughters of daughters, I…
-
7
votes3
answers227
viewsEF Core - Partitioning Filter
I am working in a database that has the following feature, 90% a clustered index that integrates two columns.: FilialID and DataCriacao. These tables are partitioned by FilialID, the simple creation…
-
7
votes4
answers1423
viewsHow to build custom queries using Entity Framework?
I have an SQL Server database that is accessed via ORM Entity Framework Core, where access to a collection of products, these products are filtered through a DTO that has the terms of the search,…
-
4
votes2
answers88
viewsWhat is the Creation proxy for in the Entity framework?
What is the purpose of disabling this feature?
-
4
votes1
answer84
viewsHow to control migrations in two distinct contexts?
I have two contexts and I would like to know how to activate each of them. For example Add-Migration Contexto 1, Add-Migration 2 How can I add new ones Migrations for each context?…
-
4
votes1
answer1788
viewsEntity Framework 7, Insert or Update
I’ve been looking for a method to check if an object exists in the base, if it exists, run a update, if there is no, insert. I couldn’t find anything anywhere that would suit me, so I made the…
-
4
votes1
answer180
viewsCustom Data Annotations for validation
I want to create a Data Annotation to be able to check in ALL pages of my application if the user who is logging in already has 1 Condomínio registered, if there is no registered condominium it…
-
3
votes0
answers132
viewsError generating Migrations Entitycore for Mysql
Following guys I’m trying to use the new Efcore being that with Mysql, I installed the following packages nuget: Install-Package Mysql.Data.Entityframeworkcore -Pre Install-Package…
-
3
votes1
answer116
viewsThe Entity type 'Personal' is part of a Hierarchy, but does not have a discriminator value configured
I am trying to generate Migrations using the command: dotnet ef migrations add InitialMigration --context MyContext and the same is returning me the following message.…
-
3
votes1
answer675
viewsGeneric Query with Predicatebuilder and Linqkit
I’ve been using Linqkit to create generic queries for a long time. One thing that always bothered me is that I always have to test if the value sent in the filter is valid. For example: Suppose I…
-
3
votes0
answers57
viewsError when using dictionary in a Iqueryable.Select() method to project columns chosen at runtime
The code fragment below aims to use the Select() method to perform generic column projections in a query, according to a list of column names provided. The program works fine if all columns are…
-
3
votes1
answer385
viewsSelf Relationship with Entity Framework 2.2
How to Make a Self Relationship with EF Core 2.2? I found a link that teaches to do with EF, but in EF does not have the Withoptional method. public class Menu { public int Id { get; set; } public…
-
3
votes1
answer269
viewsUpdate-database -script in EF Core
In EF6 I could run the "update-database -script" command from Migrations to see the script that would run in the database. How do I get this in EF Core?
-
3
votes1
answer1644
viewsEntity Framework Core 2.0 - Add-Migration does not work
I am creating a new code-first project. When trying to create Migration, using the command [Add-Migration Initial -Context LogAuditoriaContext] it simply does nothing, creates nothing, makes no…
c# asp.net asp.net-core migrations entity-framework-coreasked 6 years, 10 months ago LeoFelipe 1,455 -
3
votes0
answers113
viewsHow to use interfaces like Dbset’s in the C#Entity Framework
Hello, I’m making a solution where my entire business layer is in a separate project and in this project I created the layer relational structure from interfaces as shown in the example below: //…
-
3
votes1
answer104
viewsHow to create an Object in a Linq.Expressions.Expression and add properties dynamically to it in C#
Hi, I’m creating a library of DataAnnotations to extend Entityframeworkcore with structures that today only exist using Fluentapi. In one of them, I’m trying to recreate this block of Fluentapi:…
-
3
votes1
answer77
viewsHow to redeem data that was saved in the bank during a creation process
In some Orms Nodejs I have this feature. However, I would like to know how to rescue an entity that was persisted in the bank? For example: User has an attribute ID. If I return the item, the ID…
c# entity-framework asp.net-core entity-framework-coreasked 5 years, 10 months ago Thiago Cunha 1,356 -
3
votes1
answer248
viewsRecord Email and Phone Array in Database with Entity
I need to save an html array of telefones and Emails, in the database, but I’m not sure how to receive such data. Phone and email number can be 0 ou N, as in the image below, one can add as many…
c# asp.net-mvc-5 asp.net-core entity-framework-core .net-coreasked 5 years, 6 months ago Matheus 616 -
3
votes1
answer131
viewsAspnet Core API with Entityframework Core - Disconnected Entiades
My scenario is the following: I have an Aspnet core API that uses Entityframework for data access (postgree database). When I receive content in Json by the API (Put) and need to update the template…
-
3
votes0
answers88
viewsC# EF Core - simultaneous conflict with Trigger mariadb
I’m using EF Core with mariadb, in the database I have fields with defined default values and a trigger "before insert". In fluent mapping, I report the default values to the field normally.…
-
2
votes2
answers368
viewsEF core called the Procedure
I’m trying to use the Entity-framework-core and I have a problem, I need to call a procedure: var status = _context.Set<Usuario>().FromSql("exec LoginUsuario @chave='ROBr',…
-
2
votes4
answers60
viewsRemove null fields from a model that receives a list
I need to remove all null fields, which comes from a list of Phones, I tried to do it this way, but unfortunately it didn’t work: model.Phones = model.Phones.Where(x => x.Phone != null &&…
-
2
votes2
answers402
viewsReturn data from a Linq query to an EF Core repository
I have the Person class that relates to the Personal and Personal Tables in a one-on-one relationship. In my table Person I have the field Personnature where 0 = Person and 1 = Legal Person. A…
-
2
votes1
answer105
viewsInclude in Entity Framework from an Enumerable
I have the following entities: public class Rota { public Rota() { CidadesRotas = new List<CidadesRota>(); } public int RotaId { get; set; } public string Descricao { get; set; } public string…
-
2
votes2
answers177
viewsConverting (Mapping) a List of an entity to another reference explitically
How do I convert/map a list from one entity to another reference explicitly. Here’s an example I was able to perform with an entity: public static explicit operator UserResponse(Entities.User…
-
2
votes1
answer135
viewsError while using Middleware
I’m trying to use Middleware, so that every time a user logs into the system it is being redirected to condominium registration screen, he can not use the system until you register at least 1…
-
2
votes1
answer186
viewsWhy is EF Core updating data from other tables?
Why EF Core is actuating data from other tables? I am updating a table with EF but however I notice that EF is updating that table and still other tables. public async Task<IActionResult>…
-
2
votes1
answer114
viewsRelating distinct foreign keys in a column?
Hello, I am creating a table to register materials or services that depend on two other tables to form your cost center (Foreign key), depending on the type of registration. If I’m going to register…
-
2
votes1
answer182
viewsEntity Framework Sum and Count different status
In my ASP.NET MVC project, I’m trying to achieve the equivalent of this SQL Server code: Select e.Numero, e.ValorEmprestimo, Count(Case when pvp.IdeStatus = false and pvp.DatVencimento >=…
c# asp.net-mvc asp.net entity-framework-6 entity-framework-coreasked 5 years, 4 months ago Pedro 186 -
2
votes2
answers484
viewsHow to hide property in Efcore listing
Hello, I have a question regarding the Efcore Webapi of ASP.NET Core. I have my Service, Professional, User and Scheduling entities, where in the service I have a foreign key for the professional…
-
2
votes1
answer125
viewsHow to map a relationship using EF Core
My Pessoa entity may also be an Employee entity. I have the need that, whenever I register a Person, I must inform the Employee who registered it, being Person as Primary Key and Personal Key as…
entity-framework-coreasked 5 years, 2 months ago Master JR 1,853 -
2
votes1
answer367
viewsHow can I see the SQL generated by Entity Framework Core?
I am using version 3.1 of EF Core, and I am trying to see the SQL generated from this code: var query = Db.Set<Area>() .Include(i => i.Extratos) .Include(i => i.Coordenadas) .Where(x…
-
2
votes1
answer113
viewsDependency Injection and Generic Repository Windows Forms C#
I have a windows Forms application where I am trying to use dependency injection for some services, for this I did the following configuration initially in Program.Cs I register the services: static…
-
1
votes1
answer616
viewsMigrations Hasmaxlength x Hascolumntype
I am creating a simple test table with EF Core e SQlite Follow the first test in which the modelbuilder creates a migration (shown just below) protected override void OnModelCreating(ModelBuilder…
-
1
votes1
answer967
viewsEntity Framework Core Error
I have an error with Entity Framework core when I add Migration, the following error appears to me: System.InvalidOperationException: Cannot use table 'Atleta' for entity type 'Pessoa' since it is…
-
1
votes1
answer193
viewsMap Object value to Entity Core
I have the class public class Email { public string Endereco { get; } public string NomeExibicao{ get; } } I am trying to map in EF Core using the following code builder.Property(e =>…
-
1
votes1
answer189
viewsLINQ to SQL - Exception when giving sum() in a query that contains another subquery using LINQ
private decimal GetBankAccountCashierTotal() { var company = _context.Company.FirstOrDefault(); return _context.PersonBankAgencyAccount .Where(p => p.PersonID.Equals(company.PersonID)) .Where(c…
-
1
votes1
answer735
viewsMigration with possible data loss
When generating an update of db which results in possible data loss efcore shows the alert: An Operation was scaffolded that may result in the Oss of data. Please review the Migration for Accuracy.…
-
1
votes1
answer306
viewsHow to enable Migrations using Entity Framework Core = Windows Forms C#
I am testing EF Core in a Windows Forms project following the DDD standard. In the repository layer I created my context and in my domain I already have the Models classes defined. How do I enable…
-
1
votes1
answer48
viewsHow to show queries generated by EF core
A while ago, with a simple code within my context, I would show the queries generated by EF6 on the console or even write to a txt file... However, today I use Entity Framework Core, in an Asp.net…
-
1
votes2
answers275
viewsHow to access the database directly from my model class in an ASP.NET Core project?
In ASP.NET Core Mvc I can access Dbcontext in the Controller through the property _context represented by my class MvcNotaContext see: private readonly MvcNotaContext _context; This way I can…
-
1
votes1
answer47
viewsAccess to EF Core data
Doubt access to data efcore I have a table with many fields, I’m using EF Core for access, it is possible to return only the fields that I will actually use? Ex. in a listing, precise ID and Title,…
-
1
votes1
answer470
viewsCorrect way to use two contexts in Asp.net core with Entity framework core
I’m trying to apply what I’ve been studying and stuck in a part of contexts. What I’m trying to apply is using the Microsoft structure Identity with my application entities. Structure of Solution: -…
entity-framework-coreasked 7 years, 2 months ago Rafael Brunello 11 -
1
votes1
answer549
viewsCircular relationship with Entityframework Core
I need to relate the entity Person to Personal Registration using EF Core, but is giving the following error in Migrations: "The navigation Property 'Personal' cannot be Added to the Entity type…
-
1
votes1
answer156
viewsEntity Framework Core - Composite Key
Until version 1.0 of EF Core I was having problems doing UPDATE on a database record that contained a composite key. If I tried to change the ID value of one of the compound key fields, it was not…
-
1
votes2
answers151
viewsHow to create Function in Database with Migrations Ef core?
I created a Function in Postgresql and would like it to be generated together with the database in the initial Migration. I tried it this way and I didn’t get any results protected override void…
-
1
votes1
answer260
viewsMigrations error loading System.Configuration.Configurationmanager - Migrations
I have a WPF project that contains a app.config containing the consection string and tb have a Data layer of type Classlibrary . dot net Standard in which the Migrations folder should be created.…
-
1
votes1
answer135
viewsMap classes that inherit Id from another Entity - EF Core class
I need to map the Person and Branch classes with a one-to-one relationship, where a person will be just a branch and a branch will be tied to only one person, (A PK in Person Id and PK/FK in…
-
1
votes0
answers133
viewsEntity Code First Migrations does not find Microsoft.EntityFrameworkCore.Design
Hello, I am working on a dotnet 4.5.1 project using Entityframework with Codefirst Migrations, I have added 1 new field to an entity and I am trying to add a new Migration, but the following error…
c# asp.net-mvc .net code-first entity-framework-coreasked 6 years, 9 months ago David oliveira barbosa 11 -
1
votes1
answer1131
viewsUse Ilogger with . Net Core 2
I am studying . Net Core 2 and I have a question. I am wanting to log error in my Repository layer and only saw example in Controller. Some specific reason for this? Follows my codes:…