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
-
6
votes4
answers4566
viewsHow do I update my data in the table using the Entityframework?
var contactado = ContactadoRepositorio.ObterListaContactadoPorCodigo(procedimentoVM.CodContactadoPessoa); //obtenho o contactado pelo id obtido; foreach (var c in contactado) { var contactadoPessoa…
-
6
votes1
answer166
viewsAdd property in relation to N-N
How to add properties (columns) in an N-N relation using EF? For example, I have the class Produto: public class Produto { [Key] public int ProdutoID { get; set; } public string Descricao { get;…
-
6
votes3
answers1227
viewsIs there a Data Annotation that prevents data duplication in the Database?
How do I prevent data from being duplicated in the database using Data Annotation or via another validation?
-
6
votes2
answers2918
viewsEntity Framework WITH (NOLOCK)
We can use the NOLOCK in the SELECT, thus avoiding the blockages with the commands of INSERT SELECT COUNT(Descricao) FROM Produtos WITH (NOLOCK) Is there any way to use the WITH(NOLOCK) in the…
-
6
votes1
answer155
viewsModeling with Code First so you can exchange databases
If I generate my database for Mysql using the concept of Code First is it possible to change it to SQL Server in the future with relative ease? Need to change the classes or just the config and the…
-
6
votes2
answers312
viewsWhere to call Savechanges() when you have multiple repositories?
I am developing an application with Entity Framework, with several repositories. Each repository encapsulates SaveChanges() dbcontext. When a business layer operation uses multiple repositories, and…
-
6
votes1
answer523
viewsI’m not getting a Oracle file with Code First
Here’s what I’m doing: Folder Model dou Add > New Item follows pictures Then select ADO.Net Entity, give a name and ADD I select Code First and give Next Well in this step, I select , and look at…
-
6
votes1
answer149
viewsWhy does OFF SET slow down SQL?
I have the following SQL, generated by Entity Framework 6. SELECT [Project1].[C1] AS [C1], [Project1].[ID] AS [ID], [Project1].[CAMPO1] AS [CAMPO1], [Project1].[CAMPO2] AS [CAMPO2],…
-
6
votes1
answer170
viewsGenerate new Migrations based on all models
I need to create an Migrations with all the models created (I ended up deleting the first Migration and I am not able to create the authentication database).
-
6
votes1
answer1271
viewsRelationship Problem Many to Many in the Entity Framework
I have the following situation: To perform an authentication, I’m using the old method for a small application, for assigning levels (roles), as many examples are found all over the web. Use EF and…
-
6
votes1
answer325
viewsRun Insert in Migrations Entity Framework
I am developing an ASP.NET MVC project with Entity Framework Code First. I already checked the bank and managed the first Migrations, my question is: has how to execute a insert right after creating…
-
6
votes1
answer2378
viewsWhat are the differences in performance when using querys with EF vs ADO
What is the difference in performance when using the basic query methods SqlQuery<TElement> and ExecuteSqlCommand of Entityframework in relation to directly using the ADO.NET? If there is…
-
6
votes2
answers195
viewsInserting single quotes into null fields
I created a very simple application to simulate a small client registration, but when testing the manipulation of data by the application I could see in the database that the fields that are null in…
-
6
votes1
answer288
viewsError using Entity Framework Bulkinsert
I have an Asp.Net MVC project in . Net Framework 4.0 with Entity Framework 5.0, where I added the Bulkinsert-ef5, but in the following excerpt error occurs: using (MeuEntities context = new…
-
6
votes1
answer813
viewsSelf Relationship in EF
I’m having the following problem creating two self relationships. When rotating the Update-Database The following error message appears: Unable to determine the main end of an Association between…
c# entity-framework asp.net-mvc-5 entity-framework-6 code-firstasked 8 years, 3 months ago Lucas Ost 319 -
6
votes3
answers269
viewsHow to search and save a single field?
How can I search a single field of the table change it and save this field without having to search all fields of the table? The reason for this is simple, I have some tables that have more than 30…
-
6
votes2
answers687
viewsHow is the query generated in Linq mounted when we do UPDATE?
How the query generated in Linq is mounted when we do UPDATE? using ColWebDBContext.DBase.Banco; using System; using System.Web.UI; using System.Linq; namespace DBContext { public partial class…
-
6
votes1
answer230
viewsFilter Postgresql Information on Windows Forms screen using Entity Framework
Is there any way to search for the information in postgresql by nickname? But without using alias, only in the field register in the table I already enter the real name for the field? Example:…
-
6
votes3
answers504
viewsMap Many to Many in the Entity Framework
I’m having a problem mapping with the Entity Framework. I have two models, "project" and "company", where in the "company" there can be several "projects". public class Projeto { [Key] public int Id…
-
6
votes1
answer83
viewsDoubt about Many-to-Many EF Relationship
I am doubtful in a following rule: I have N Products and N Coins. From this relationship I will have the table Productomoeda: ProdutoMoeda Id - ProdutoId - MoedaID - Nome 1 2 1 ProdutoNome +…
-
6
votes2
answers574
viewsFaster way to save multiple entities with Entityframework
I have a performance problem in one method, in addition to causing the full use of the CPU server that method takes a long time to run. internal async void NotificacaoIosTodos(string titulo, int…
-
6
votes1
answer873
viewsEntity Framework Update Database
When executing the command Update-Database I have the following error Could not load file or Assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, Publickeytoken=b03f5f7f11d50a3a'…
-
6
votes2
answers905
viewsHow to create a sequential number that does not repeat, per user
Work on a bill issuance project, in this project exists the entity Emissor. My database Sql-Server may have several emitters. Each issuer can issue their tax bills. Each invoice shall have a…
-
6
votes3
answers1299
viewsShould every table have Primary key?
I believe my question is both conceptual and technical. My whole problem started when I made an SQL Server database and in it there were some tables without primary key, such tables would serve…
c# asp.net-mvc sql-server entity-framework entity-framework-6asked 5 years, 5 months ago Nelson Francisco 147 -
5
votes5
answers2481
viewsDo not allow saving duplicate records
I am developing a system using ASP.Net MVC and Entity Framework. How do I not allow equal data to be recorded in a table? For example, don’t allow login: x to be registered more than once.…
-
5
votes1
answer2001
viewsHow to List Users with Asp.Net MVC 5
I am using Visual Studio 2013, I am creating a new Asp.NET Web Application project using MVC and authentication by "Individual User Account". I would like to know how to list all registered users.…
-
5
votes2
answers221
viewsWhat is the reason for using Dbmigration in Codefirst?
What is the goal of using Dbmigration when developing a project using Codefirst? Using it is a good practice, or is something that does not cause major impacts on the implementation and/or…
-
5
votes1
answer496
viewsChanges to the database with Asp.net MVC 5
I am starting some independent projects using Asp.net MVC 5 with Entity Framework, and more learning from the technology. And at the moment a great doubt arose. I used the code generated through a…
-
5
votes2
answers475
viewsIs it feasible to use more than one Dbcontext for in the same database?
I’m developing a new application on ASP.NET MVC and searching saw some examples of applications with more than one context. Let’s say my application has several different modules, but all entities…
-
5
votes3
answers1128
viewsEntity Framework - Update nested lists
I have the following schema in my Mysql BD: Models have a list of standard_images and each standard_images has a list of standard_regions. I must use Entity Framework 5.0.0. I have a model with 3…
-
5
votes1
answer186
viewsSimulate the same SQL in the Entity Framework with Linq and Lambda?
Having this data model I want to generate a SQL thus in the Entity Framework with Linq and Lambda? Support data SELECT Pessoa.PessoaId, Pessoa.Nome, Pessoa.PessoaPaiId, PessoaPai.Nome AS NomePai,…
-
5
votes1
answer601
viewsCan foreign key be null in Entity?
I’m having a hard time in a project. I created two tables (Union and Schoolhouse), whereas the PK table Union is FK on the table Schoolhouse. But this FK may be void, i.e., the Schoolhouse may…
-
5
votes2
answers213
viewsValue priority data ordering using LINQ
I have a "status" table with the following values: ID 1 = Ativo ID 2 = Novo ID 3 = Excluido How would you return a list of objects (that have the status object) prioritizing, coming first, those…
-
5
votes1
answer263
viewsHow do I sort Lambda by a List property?
I believe this has been asked before. I researched but did not find. I’m having trouble with this consultation, specifically in charge ThenBy that tries to sort the sub-list of objects. I know it is…
-
5
votes1
answer684
viewsIs it possible to use composite key for Entity Framework with Model First?
I have the modeling down and will need to map composite keys like the Embedded id of Hibernate, but in the Entity framework using the model first, it is possible ?…
-
5
votes1
answer5990
viewsError updating entries in Entity Framework
I have the following code for mapping my application, but when I will try to make a insert gives the following error. An error occurred while updating the Entries. See the Inner Exception for…
entity-frameworkasked 10 years ago Rabelos 161 -
5
votes2
answers351
viewsUpdate data using LINQ
I read that LINQ should be used for queries, but in the context below, the best way I found to update was by using the let. var produtos = from o in orcItens join p in Produtos on o.Id equals p.Id…
-
5
votes1
answer301
viewsTwo dependent combobox using Linq to sql
How do I fill two combobox’s with Linq to sql where in a combobox for example I have countries and in another I have cities? How do they automatically change the values? I leave the image below how…
-
5
votes2
answers305
viewsOnly constructors without parameters and initializers are supported in LINQ to Entities - Asp.Net MVC
I’m developing an application that manages courses. The student, when entering the registration screen and clicking on the "registration" button, is associated to a course, that is, is enrolled. So…
-
5
votes2
answers814
viewsWhat is the most "clean" and clear way to validate entities using the Entity Framework
I am using the Entity Framework for data manipulation. The project is divided into 2, one containing the domain entities and the other the mappings (Fluent Api). I need a clear "clean" way to…
-
5
votes1
answer841
viewsAdd Migration and update at runtime Entityframework
I am developing an application and the need arose to add Migration and run the update at runtime. I already have the whole part that loads the modules: public class ClientContext : DbContext {…
-
5
votes2
answers439
viewsEntity Framework | Double property that allows null
My property allows values double and values null. In the SQL Server Database it is set to decimal(18, 2). But when seventh some value (ex: 5.00), makes the mistake below. Error: The 'Rating'…
-
5
votes2
answers1613
viewsCan cause cycles or multiple paths to cascade. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY restrictions
I have a class that will have two FK pointing to the same table, so Entity Framework returns the error: Can cause cycles or multiple paths to cascade. Specify ON DELETE NO ACTION or ON UPDATE NO…
-
5
votes1
answer1081
viewsHow to call Procedure using Asp.net MVC with Entity Framework
In an application Asp.net mvc, using ADO.NET with Entity framework and mysql, I have a procedure, that returns a listing. CREATE PROCEDURE SP_CATEGORIAS() BEGIN select * from (select a.id,…
-
5
votes2
answers296
viewsHow to make a LINQ/lambda and consume it in the view?
I have an object called Radio: public class Radio { public int RadioId { get; set; } public string StreamUrl { get; set; } public bool Ativo { get; set; } public bool Mp3 { get; set; } } I’m doing a…
-
5
votes1
answer170
viewsEF is giving Timeout in a query that should be instantaneous
When I run the SQL generated by the direct EF on Sqlserver it runs with less than 1 second. When it runs through the timeout application it takes more than 30 seconds. I’ve seen a lot of this…
-
5
votes4
answers96
viewsWhat is the best solution ? Getbyid with a non-existent id in the BD
I’m making a call in my Pository but CPF does not always exist in the BD. When it does not exist in the database I get the following error. Repository public VendedorModel GetById(int CPF) { using…
-
5
votes1
answer773
viewsWrite include date using Entity framework
I believe there was a misinterpretation, I’m posting the code to be better understood. I am using a project for my EF Repository is inside it I have: Note the doubt in //companySalvar.DATA_IND =…
-
5
votes2
answers109
viewsQuestions about Fluent API relationship for EF 5
I have two classes: User > Contains your PK (ID). User > Contains the user ID(FK). Class User.Cs public Usuario() { this.UsuariosP = new List<UsuarioP>(); } public int Id { get; set; }…
-
5
votes1
answer549
viewsEntity with multiple members of the same type in the Entity Framework
When we have two entities related to Many-to-Many and create the navigation properties correctly Entity creates an extra table to configure that relationship. In the case I’m working I have a…