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
-
61
votes3
answers8159
viewsWhen to use Entity Framework with Repository Pattern?
Lately I have several examples of Repository Pattern homemade on questions about Entity Framework. But the Entity Framework already implements a Repository Pattern, which in this case is the Unit Of…
-
41
votes4
answers4635
viewsTo what extent is it not advisable to use an ORM?
I am working on a very large system using . NET (ASP.NET MVC) the application requires a critical level of performance. How worthwhile or not to use a ORM? Is there a tool that I can compare in…
sql entity-framework software-engineering nhibernate ormasked 10 years, 7 months ago Tuyoshi Vinicius 4,046 -
24
votes3
answers4038
viewsWhat is the difference between using virtual property or not in EF?
I have my models public class Cliente { public int Id {get;set;} public string Nome {get;set;} } and public class Pedido { public int Id {get;set;} public int ClienteId {get;set;} public virtual…
-
21
votes5
answers6769
viewsShould I use GUID or int as the primary key?
I’m about to start a new project in MVC 4 with Entity Framework, searching I found several examples here in Sopt of models that use GUID as ID and some doubts have arisen me: What is the advantage…
-
18
votes2
answers484
viewsIs there an opposite for `contains`?
I have a list: List<int> lista1 = new List<int>(); lista1.Add(1); lista1.Add(2); lista1.Add(3); List<int> lista2 = new List<int>(); lista2.Add(1); lista2.Add(2); To get the…
c# .net entity-framework linq lambda-expressionsasked 9 years, 4 months ago Jedaias Rodrigues 6,718 -
16
votes2
answers1245
viewsWhy is Addrange so much faster than Add?
I’m working on a data integration between two databases, and I’m using Entity Framework for that reason. I then generated the following code, which iterates each record in the Base Situations table…
-
16
votes1
answer8416
viewsHow the Lazy Load Entity Framework works
It’s the following guys, from what I saw on Entity to use the Lazy Load you leave the property without keyword virtual, and Ager with the virtual. However, I saw in some blog posts that people use…
-
16
votes1
answer1184
viewsBest Practices for Insertion, Modification and Deletion with Entityframework
For deletion of records you may not have, but for Insertion and Change I believe there should already be something discussed. Probably the best practice on Insertion and Amendment is Viewmodel s,…
-
16
votes3
answers3624
viewsWhen to use asynchronous or synchronous method?
When to use asynchronous or synchronous methods in controllers (index, search, delete, create) of ASP.NET MVC applications? Can I lose performance? In which situations should I use one or the other,…
c# asp.net-mvc .net entity-framework asynchronousasked 7 years, 7 months ago George Wurthmann 4,415 -
15
votes5
answers17754
viewsHow to solve accent problems with ASP.NET MVC?
I’m having problems with accentuation in ASP.NET MVC 5. I am using Visual Studio 2013 Professional and in the application . Net 4.5. SQL Server 2008 and Entity Framework 6. The browser is Google…
c# asp.net-mvc asp.net-mvc-5 entity-framework visual-studio-2013asked 10 years, 9 months ago user3628 -
15
votes2
answers1101
viewsEntity Framework Core x Entity Framework 7
What are the main differences between Entity Framework Core and Entity Framework 7? There are scenarios where one is more suitable than the other. It’s so much version and so much name change that…
-
14
votes3
answers261
viewsWhat is the advantage of using the Set<> method?
What is the advantage or difference in using the method Set<> and I can do the same thing without him as in Alternative 2? Alternative 1 var aluno = contexto.Alunos.First(x => x.Id ==…
-
13
votes2
answers141
viewsHow to Lambda in Extension Methods with Multiple Lists?
There are the following Objects: public class Objeto1 { public List<Objeto2> PropObj1 {get; set;} } public class Objeto2 { public List<Objeto3> PropObj2 {get; set;} } public class…
c# .net entity-framework linq lambda-expressionsasked 9 years, 4 months ago Jedaias Rodrigues 6,718 -
13
votes1
answer498
viewsWhen does the Entity Framework execute the query of a Iqueryable?
I am developing a method for an API that consists of the following: fetching all customer reviews and, if specified, limiting the amount of records that will be returned. For example: public…
-
12
votes2
answers5287
viewsHow to implement the Repository Standard in C# with EF?
I want to make an implementation of the standard Repository where I will be using the Entityframework and have the following: Interface IRepository: public interface IRepository<T> where T :…
-
12
votes1
answer680
viewsCode First versus Database First?
I’m used to creating projects on Asp.net-MVC with Entity Framework Database First. From a modeling, the database and the system are created. However, I see a lot of programmers prefer Code First,…
asp.net-mvc entity-framework code-first database-firstasked 10 years, 1 month ago Andre Figueiredo 5,030 -
12
votes2
answers815
viewsHow does the logic of Where in the Entity Framework work?
I’m studying C# and I just made my first query in the Database: using System; using System.Data.Entity.Core; using System.ComponentModel.DataAnnotations; using…
-
11
votes2
answers1153
viewsConsulta Lambda
I have the following consultation at T-SQL: SELECT TOP (60) COUNT(*) AS QTD, SUM(Duration) AS Total, AVG(Duration) AS Media, MIN(Duration) AS Menor, LEFT (TextData, 80) AS TextData FROM Traces WITH…
-
11
votes2
answers121
viewsIs there an alternative to Removeat()?
I am using Entity Framework in an ASP.NET MVC project where I have a simple list of strings and need to remove only the first item. I used the following command: minhaLista.RemoveAt(0); Well, but…
-
11
votes2
answers309
viewsWhat’s the difference between Savechanges and Submitchanges?
Within the context Entity Framework what is the difference between SaveChanges and SubmitChanges? When I should wear one or the other?
-
11
votes2
answers325
viewsAre DDD and Entity Framework mutually exclusive?
I was exchanging comments with two users here at SOPT about DDD and Entity Framework. I said that DDD and Entity Framework are not mutually exclusive. Or are they? References: What is really the…
-
11
votes3
answers649
viewsWhat is the Target Framework and what is it for?
I work for a while with .NET and I was asked about the target framework of my projects. I understand what it’s for but I couldn’t explain it simple and clear what exactly is.…
-
10
votes2
answers1468
viewsEntity Framework is saving duplicate values when saving entities with relationship N to N
I have an entity called Book that has among other attributes a list of categories. In my model a book can have multiple categories and vice versa, so we have a relationship N to N. EF therefore…
-
10
votes2
answers7394
viewsEntity Framework update and delete associative entity
I have a student table that has many to many relationship with the course table. Thus resulting in the table CursoAluno. I would like to know the correct way to the update and the delete table…
-
10
votes2
answers5236
viewsRelationship N for N and One for N with Codefirst Data Annotations
How can I Relationship N to N and One to N using Data Annotations? For example: A sales drive has a user, and a user can have multiple drives. This same sales movement has several products, and each…
-
10
votes1
answer2456
viewsReturn Object Code as soon as inserted
I need to do an Insert in the Entity Framework and at the same time returns the code of the inserted object, thus preventing new access to the bank.
-
10
votes3
answers1631
viewsConcurrency control in database insertion
I have a competition control problem in entering data from a table. The scenario is as follows:: There is a table that records daily data according to user requests, and this data cannot be…
-
10
votes1
answer398
viewsDoubt about mapping in Entity Framework 6. "readonly" properties
I have three tables in my bank: TB_COLABORADOR TB_JORNADA TB_JORNADA_COLABORADOR To TB_JORNADA_COLABORADOR makes the association of employees with the journey and vice versa through the fields…
-
10
votes2
answers367
viewsDifference between . NET Framework for Entity Framework
I have an Asp.Net MVC project that when clicking properties the following information is displayed: When opening the file packages.config I could see that other information: After all, what exactly…
-
10
votes1
answer1562
viewsUnit Of Work + Ioc + Idisposable
I’m putting together a project that I use Uow to facilitate the issue of transactions. In some scenarios, I use several repositories, persisting the data in memory to save at once in the BD using a…
-
9
votes2
answers4809
viewsEntity Framework with Oracle Banks
I am creating an application in which will use an Oracle database, but when inserting the .edmx (Entity Data Model) I came across the following situation! I can’t create a connection with Oracle…
-
9
votes1
answer936
viewsIn the Entity Framework, do the Singleordefault() and Firstordefault() methods exhibit different behaviors?
What are the differences between SingleOrDefault() and FirstOrDefault(), and when to use?
-
9
votes4
answers2911
viewsEntity Foreign Key Framework
My domain: public class SBE_ST_CorpoDocente { public int Id { get; set; } public string Nome { get; set; } public virtual ICollection<SBE_ST_Curso> Cursos { get; set; } } public class…
-
9
votes1
answer188
viewsHow to use Ivalidatableobject?
How to use the IValidatableObject not to validate a foreign key property during a registration? I want to validate only the foreign key in the edition.
-
9
votes1
answer209
viewsStrange property initialization
While reading a tutorial on Entity Framework, I came across an example of code where there was a line that, for me, is unknown: Student stud = new Student() { StudentName = "New Student" }; I…
-
9
votes2
answers1167
viewsForeach of C# vs Foreach() of EF6
Follows code: ForEach() of EF6: var result = ctx.Table.Where(x => x.User == "João").ToList(); result.ForEach(x => x.Read = true); ctx.SaveChanges(); foreach of the C#: var result =…
-
9
votes1
answer1372
viewsPass two templates to a sign-up view
I have a login registration screen. I have to fill it with values registered in the database. Follows the codes: Models: public partial class Aba {…
-
9
votes3
answers1480
viewsHow to make a query through LINQ ignoring accents?
I wonder if it is possible to make a query with LINQ to compare two strings and ignore their accents. That without my Collation in the database is set as AI (Accent Insensitive) and I don’t need to…
-
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…
-
8
votes2
answers1261
viewsHow to get all records from a mixed table generated by class inheritance when using Entityframework 6?
I have a class structure in the following form: public class Pessoa { public int Id {get; set;} public string Nome {get; set;} } public class Membro : Pessoa { public int CargoId {get; set;} public…
-
8
votes2
answers362
viewsHow do I convert LINQ to SQL for Mysql?
I am trying to remove the use of SQL statements from within the system (to make it flexible as to which database will be used), use instructions Insert, Update and Delete via stored Procedure…
-
8
votes2
answers539
viewsEntity Framework - Bank Compatibility
I was reading a article that demonstrates the method of using the Entity Framework for connection to Mysql database, however, the article demonstrates techniques quite different from the ones I use.…
-
8
votes2
answers1854
viewsPagination C# MVC Asp . NET
I have a problem with paging performance with Entity Framework and SQL SERVER, first it does getAll and then list the pagination var bdPergunta = new PerguntaRepositorioEF(contexto); var pergunta =…
-
8
votes1
answer189
viewsDifferent connectionstring for different builds
I have two Connection string, one when I am in development that uses my local bank and the other for when I deploy the application in Azure. I want the app to know which one to use depending on the…
-
8
votes3
answers1242
viewsLINQ with Where condition using variable
I have the following table: USUARIO Nome | Idade João | 21 Maria | 18 I want to do in only one consultation return all users, or return only users of specific age based on a C variable#. Also by…
-
8
votes2
answers339
viewsWhere to put Data Annotation? View Model or Model?
Using Entity Framework Code First, with view model and model. To create a column with varchar(2), need to put the MaxLength(2) in the model and in the view model?…
-
8
votes2
answers9392
viewsSerialize object list for JSON: A circular Reference was Detected while serializing an Object of type
I’m trying to Serialize a list of objects to Json and have received the following error: An Exception of type 'System.Invalidoperationexception' occurred in Microsoft.Web.Extensions.dll but was not…
-
8
votes1
answer173
viewsAddorupdate - use array as parameter
I’m doing tests with Entity Framework and I had a problem when placing a array as a parameter. Why when I assign the conversion of array in a function variable and directly in the method parameter…
-
8
votes3
answers1381
viewsWhat is the difference between Data Annotations and Fluent API?
What is the difference between Data Annotations and Fluent API? Is there a restriction between one or the other? Improve performance or are just two ways to do the same thing?
-
8
votes1
answer1373
viewsHow to handle duplicate key error?
How do I handle duplicate key error? I need to display message to the user that the "Item is already registered" Something like that: try{ //tenta inserir no Banco de Dados…