Most voted "entity-framework" questions
ADO.NET Entity Framework is a set of tools for object-relational mapping or Object-Relational Mapping (ORM) for the . NET Framework by Microsoft, Since version 3.5 SP1.
Learn more…1,214 questions
Sort by count of
-
8
votes4
answers542
viewsWhy use block using in ASP.NET MVC?
The block using {} works in the same way in both web applications and desktops in the sense of when we use it in controller? It is a good practice to declare it in the actions that there is contact…
-
8
votes2
answers708
viewsCode First and Calculated Fields
I have a class Pedido, which has a calculated field, which is the order value, composed of the sum of the items minus the discount. public class Pedido { public ICollection<PedidoItem> Itens {…
-
8
votes2
answers2267
viewsHow Viewmodel works on Asp.net mvc
I have a similar situation that question where I need to save several models at once and relate each. I would need to sort of cascade to first save one entity and then go saving the others, because…
-
8
votes1
answer377
viewsTo automatically fill fields when saving object in database
I have a system, in ASP.NET MVC which implements a form of audit, that when a user enters or updates an object into the database, some information is saved to an audit table automatically. The…
-
8
votes4
answers1003
viewsProblem saving a change using Entity Framework
I am trying to persist a change I make to a record but am getting this error: System.Invalidoperationexception: 'A referential Integrity Constraint Violation occurred: The Property value(s) of…
-
7
votes2
answers2415
viewsStored Procedure in Entity Framework without edmx template
I have a project that uses the Entity Framework without a model edmx, we register the entities manually create a class and insert it into the context. Someone uses this format and knows how to…
-
7
votes4
answers4043
viewsBest practices in using BD connections via Entity Framework
When defining the context class in the Entity Framework (example): public class Context : DbContext { public DbSet<Usuario> Usuarios { get; set; } public DbSet<Categoria> Categorias {…
-
7
votes3
answers1774
viewsUpdate generating duplicate key error
I have a web application on . net 4.5.1 with MVC and Entity framework. Error occurs in a basic CRUD. I recover the object that will be the model sent to the view with the following code: Professor…
-
7
votes4
answers298
viewsHow to implement an Objectset wrapper that works with Linqtoentities?
I need to create a wrapper for ObjectSet to create a centralized access control. The goal is to implement CA without making changes to existing queries in the system, which in this case are spread…
-
7
votes2
answers4310
viewsHow to prevent a property from being mapped to an entity in the Entity Framework?
I need to enter a property in the model class, but when I enter the code first, it says the table already exists and changes have been made. My code: public class Data { [Key] public int Id { get;…
c# entity-framework asp.net-mvc-4 property code-firstasked 10 years, 8 months ago Luciano Azevedo 402 -
7
votes1
answer3147
viewsHelp with setting up Dbcontext with Entityframework using good practices
I have my application divided into layers with Class Library and my layer with the Entity Framework, where I set up the DbContext, is the Repository. My inherited Dbcontext class: public class…
-
7
votes1
answer183
viewsLambda with different contexts
Is there any way to join two or more tables using Lambda and two different contexts?
-
7
votes2
answers5079
viewsHow to count records (SELECT COUNT) in Linq
How to count records that a query would return in Linq (Entity Framework) in C#? The equivalent in SQL is to do a SELECT COUNT(*). Note that I want to receive the count of records straight away,…
-
7
votes1
answer244
viewsHow to support user-added columns without updating the EF model?
I have an app C# with a model Entity Framework 6 "Database First" created from the basic structure of a database SQL Server, which belongs to a third party software. Users of this software can add…
-
7
votes1
answer334
viewsSqlserver English Error Messages - (Localdb) v11.0
I’m developing an app with Entity Framework 6 using the approach Code-First. I want to configure Sqlserver (Localdb) v11.0 to display error messages in English without using SQL Server Management…
-
7
votes1
answer1281
viewsGood Practice when modularizing an application with EF and multi-bank
Let’s say I want to model an application on .NET using the EntityFramework as ORM and use one of its advantages, to be "generic" for several RDBMS. So, for example, I want my application to agree to…
-
7
votes1
answer2089
viewsQueries in Asp.net mvc with Entity framework
I’m starting a project in ASP.NET MVC 5 with Entity Framework 6, along with studies in mvc. This to have a better learning, and I came across the following doubt. In the controller have the method…
-
7
votes1
answer10316
viewsHow to fix Entityvalidationerrors
Hi, I need a help. After compiling my project I am getting an error: Validation failed for one or more entities. See 'Entityvalidationerrors' Property for more Details. I have already found that…
-
7
votes3
answers1618
viewsHow to intercept exceptions when working with the Entity Framework?
I want to handle errors returned by Entity Framework. In this example I am forcing the insertion of a duplicate record (Name already existing in the database and the table column is configured as a…
-
7
votes1
answer404
viewsCode First Mapping with Data Annotations
I am creating a project using mapping through DataAnnotations with Code First (similar to the Hibernate), without the use of FluentAPI. It turns out that in implementing this process, some…
-
7
votes1
answer310
viewsMany Update to Many Entity Framework c#
Good morning, I am having difficulty updating a record with entityframework, I will inform the whole structure below. In short, I have a register of artists, where these artists are related to…
-
7
votes2
answers1398
viewsReturning a list using select new with LINQ
I can do it: var filial = (from f in base.EntityContext.vw_filial select f).ToList<vw_filial>(); But I want to do something like this: var filial = (from f in base.EntityContext.vw_filial…
-
7
votes3
answers629
viewsEF6 + Postgresql - 22021: invalid byte Sequence for encoding "UTF8": 0xc9 0x52
I am trying to get data from a Postgresql database with Enconding SQL_ASCII, but in some records I get error message "22021: invalid byte Sequence for encoding "UTF8": 0xc9 0x52" I have tried to set…
-
7
votes4
answers1193
viewsWhich DBMS to use so that it can be installed on the client’s computer to run a C#application?
I am developing a small C# system that will be implemented on client computers in the future, accessing a local database. Initially I was going to use SQL Server, but I would have to install it next…
-
7
votes2
answers1573
viewsHow to access next and previous record with C# using Entity Framework
I am developing a Windows Form application, with Entity Framework 6 + Mysql. As is common in systems, I have in each form navigation buttons (First Record, Previous Record, Next Record, Last Record)…
-
7
votes2
answers548
viewsMemory error when entering millions of records using Entity Framework
I am using the Entity Framework to Insert and Update Thousands of Records. At first it was slow, but after putting the code down it improved the speed. db.Configuration.AutoDetectChangesEnabled =…
-
7
votes1
answer104
viewsProblem with . Include() in Entity Framework(Postgres)
I’ve been having a problem with Entityframework, it’s as follows: When I use the ORM(.Include) string to give a Join in tables with foreign keys, it automatically changes the name of the keys in the…
-
7
votes2
answers611
viewsSuggestion Migration System and modeling of individuals and legal entities in system with Entity Framework
Well, here’s the thing. I have a database that has the purpose of making a company’s ledger, basically this bank has a table CaixaCorrido with the columns Id, PessoaNome, DataHora, Descricao, Valor,…
-
7
votes1
answer94
viewsUpdate to 2K records <Clients> how to do a single update instead of 2k separately
I have a Customer Model and need to do an update on EnviadoEmailCobranca para 0 I’m doing like this: var clientes = db.Clientes.Where(w => w.Status == 4); foreach (var item in clientes) {…
-
7
votes3
answers414
viewsHow to change the structure of a LINQ query at runtime?
I have the following example of a program that implements the EF (Entity Framework). The structure of the database and the application is defined as follows: Table Pessoa: Primary key field:…
-
7
votes1
answer129
viewsHow to map an image attribute by Fluent API?
I would like to know how to map an attribute of the type image of SqlServer by the Fluent API. In my bank I have the following table: CREATE TABLE [dbo].[ProdutoFotoERP]( [ProdutoFotoID] [int] NOT…
-
7
votes2
answers512
viewsSort Datetime field only by Date part
I have a property of an entity that’s like DateTime? and in SQL Server is of the type datetime also. I need to make a query that sorts by date, but without considering the time, because in this…
-
7
votes1
answer1804
viewsThe Entity or Complex type '*' cannot be constructed in a LINQ to Entities query
I can’t do this? public List<Filial> GetAll() { //Mostra todos os registros incluindo os desativados para os Administradores var ret = _db.Filiais.AsNoTracking() .Where(e => e.Visible)…
-
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,…
-
7
votes2
answers611
viewsWhat is the purpose of using UUID (version 4) as "Primary key"?
I have noticed that some places have switched the ID (generated by autoincroment, depending on SGDB) by UUID, usually use version 4 of UUID which is based on a pseudo-random system, the question is…
database entity-framework laravel-eloquent uuidasked 4 years, 2 months ago Guilherme Nascimento 98,651 -
6
votes1
answer857
viewsWhy doesn’t Visual Studio 2013 let you use version 4 of the Entity Framework?
I don’t know why, but whenever I try to update Object Model from an old project we have, Visual Studio 2013, asks if we want to keep version 4 of EF, but even marking the right version it updates…
-
6
votes4
answers2718
viewsGenerate sequential Ids without losing the sequence
For Identity do not want, because it breaks the sequence if something happens. Max() + 1, I find it very vulnerable and slow when you have a lot of records. So I ask you, is there a way that someone…
-
6
votes1
answer1827
viewsHow to know which SQL is generated by the ORM Entity Framework?
With the use of ORM, and the practice employed we forget that they generate SQLs and return Objetos (vice versa). How can I find out at runtime the SQL generated by Entity Framework right in the…
sql entity-framework entity-framework-6 lambda-expressions linq-to-entitiesasked 10 years, 5 months ago user6026 -
6
votes2
answers26381
viewsProblem connecting to SQL Server 2012 database on IIS
I cannot run my system queries on IIS, when running in Visual Studio I can get the result easily. The mistake I get when I try to do something is this::…
-
6
votes1
answer776
viewsReplicate/Copy elements from multiple tables
I have the following situation: The user has defined an establishment, where he has filled in data in two tables, and intends to replicate/copy all the same data, changing only the id of the…
-
6
votes3
answers1328
viewsReturns Json of object in C# with Entity Framework
I’m having a problem returning a Json using Entity Framework. The code I’m using is: [AcceptVerbs(HttpVerbs.Get)] public JsonResult Item(int agendaHorarioID) { using (var db = new ERPContext()) {…
-
6
votes2
answers429
viewsHow to filter a list asynchronously using LINQ?
Example of code without the use of async: var products = db.Products.Where(_ => _.UserId == currentUserId); How do I make this asynchronous query taking into account that the Where of Linq does…
-
6
votes1
answer2258
viewsHow to fix the unrecognized Attribute 'name' error in Webconfig?
I am developing a web project in VS 2012, this application connects with a Mysql database developed in Mysqlworkbench 60 CE with Mysql server 5.6, I have referenced in the project the…
-
6
votes1
answer54
viewsRelationships Does EDMX only affect performance?
I have a question about the Entity Framework. Here at the company where I work, the tables are generated in the bank without any relationship, until the fields are created that will be foreign keys…
-
6
votes3
answers780
viewsIs it feasible to change databases in an existing system?
I’m starting a project in ASP.NET MVC 5 with Entity Framework for a customer, where the customer has chosen to use a free database, in this case the Mysql. However, with the growth of the…
mysql asp.net-mvc entity-framework software-architectureasked 10 years, 2 months ago Erico Souza 2,188 -
6
votes3
answers1195
viewsEntity Framework many relationship x many extra field
Good morning, I’m studying the Entity Framework Code First and I’m wondering how I should create an Nxn model with extra information in the relationship table. For example: Let’s assume the…
-
6
votes3
answers407
viewsHow to implement the standard presented in C# with Entityframework?
I’m thinking of a way to apply the pattern (multi-tenant), raised in that question (Standard that has contributed to the reliability of software that needs to meet complex models such as…
-
6
votes1
answer130
viewsTime difference in Linq
I am using Entity Framework, and I have a condition that has not worked very well: .Where(x => ((DateTime.Now - (x.DataInicio.Value == null ? DateTime.Now : x.DataInicio.Value)).TotalMinutes)…
-
6
votes2
answers1387
viewsSimplify LINQ query with Contains
I have two questions regarding the LINQ consultations below: { //lista de itens do orçamento var ids = itensOrcamento.Select(p => p.Id); //Produtos - todos produtos cadastrados var produtos =…
-
6
votes2
answers3589
viewsEntity Framework 6 does not create database
I created a c# WEB MVC5 project in visual studio 2013, installed Entity framework 6 and created my classes("entities") as well as Dbcontext with the respective Dbsets. Inside the WEB.Config I set up…
asp.net-mvc-5 entity-framework entity-framework-6 ormasked 9 years, 12 months ago Cleiton Ribeiro 757