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
-
0
votes1
answer254
viewsChange only edited columns
In an application I am developing, when trying to update only the fields that were changed the Entity Framework is also changing the fields that do not need. Repository code: public void Update(T…
asp.net-mvc entity-framework asp.net-mvc-5 entity-framework-6asked 6 years, 5 months ago Matheus Daumas 37 -
0
votes1
answer25
viewsStay with input text filled after changing view Asp.net
I’m in the following situation I have a view with a certain field, when clicking a button it calls a certain view, it would need that when clicking a button of that other view, it called this…
-
0
votes1
answer122
viewsError while Updating using Entityframework Core
I have a layered project using DDD and am having trouble updating a record of my Personal class. public Task Handle(UpdatePessoaSituacaoCommand message, CancellationToken cancellationToken) { if…
-
0
votes0
answers129
viewsGet User Entity ID
I’m trying to get the user id and save in the table, here’s how I referenced in the Foreignkey table: public string FuncionarioId { get; set; } [ForeignKey("FuncionarioId")] public virtual…
-
0
votes0
answers38
viewsNot getting the correct core.net User Id
I’m using ASP.NET CORE 2.0, and I need to get the logged in user id. This is my Account Controller: [Route("[controller]/[action]")] public class AccountController : Controller { private readonly…
-
0
votes1
answer126
viewsWhere with date and time - Entity Framework
I am making a select with Entity framework. where I need to use Where, with date and time, in the select of SQL SERVER, I would do so: select dbo.contas_receber.id,…
-
0
votes0
answers62
viewsSelect with Entity does not work
I have this method that makes me a select but it does not return me anything. [WebMethod] [ScriptMethod(UseHttpGet = true)] public JsonResult GetContratos() { List<object> resultado = new…
-
0
votes1
answer215
views(Localdb) Error after Update-Database command -> "Cannot attach the file ...."
I am trying to use Sql Serve Localdb in an application with Entity Framework and Migrations, but when I give the Update-Database command, the following error occurs: Cannot attach the file 'C:…
c# .net entity-framework entity-framework-6 migrationsasked 6 years, 3 months ago Márcio Sebastião 769 -
0
votes1
answer464
viewsHow to add include by expression in Repository Pattern C#
I am creating a Repositorybase (Repository Pattern) with Entityframework Asp.Net Core, and in it I am creating a Where method, where I pass a Where expression of the entity. So far the method works…
asp.net-mvc asp.net entity-framework include repositoryasked 6 years, 3 months ago Nicola Bogar 123 -
0
votes1
answer65
viewsWhere it doesn’t work when listing all records - Entity Framework
I need to return all records containing the branch informed using the clause where, only that the Entity Framework is returning all records ignoring what is in the where. Where am I going wrong?…
-
0
votes1
answer94
viewsMethod that works without I call you directly
I’m messing with the Entity Framework and I was mapping to a Many to Many class. What happens is I used a method I can use inside the DbContext to rename a table, and it works smoothly. But I was…
-
0
votes2
answers96
viewsChange a Generic Repository method to return with Asnotracking - EF Core
I have a generic repository, in particular the method GetbyId, in which I wish to change it to return a result with AsNoTracking or not as needed. How do I do this? My Interface: TEntity GetById(int…
-
0
votes0
answers39
viewsOne-to-zero mapping with Entity framework
Good afternoon, I have a document table that has relationship 1 to 0 with another table of Usuario to return the user name, however I am given the error: Specified conversion is not valid. My…
-
0
votes1
answer71
viewsEntity Framework Core 2 - Recursive research into many-to-many relationships
I made a many-to-many relationship using EF Core 2, Code First method. Second seen at that link, it is necessary to create a Join entity: public class ClienteModel { public int ClienteId { get; set;…
entity-framework asp.net-core entity-framework-core .net-coreasked 6 years, 2 months ago Matheus Oliveira 51 -
0
votes0
answers275
viewsComposite key mapping Entity framework
Good afternoon, How do I map composite key in my entities, in case 1 entity calls document and its PK is by the property ID and WEBID, and it does FK with the User as I would in that case? Document…
-
0
votes0
answers97
viewsI can’t solve No Persistence Provider for Entitymanager named
I searched on various forums, made all the suggestions I could find and still could not solve. I don’t know if it’s because of the archetype of the design, but it’s the pattern I’m using. Can…
-
0
votes1
answer206
viewsUsing Identity with Entity Framework to relate one-to-Many methods to other tables
In my scenario a user has several craft and a vessel has several notes. So I need to relate the user to the vessel so that this user can see these notes. I’m using the MVC 5 project’s default…
-
0
votes1
answer79
viewsAlternative to Unit of Work + Repository for Dbcontext sharing
I’ve seen many times people talking that it makes no sense to use Unit of Work + Repository with Dbcontext Work unit (Unit of Work) with repository Supposedly it would be "more certain" to use…
-
0
votes1
answer230
viewsHow to implement password encryption?
I want to implement password encryption in user registration. I found here in stackoverflow this post teaching how to use cryptography, but I’m in doubt where to add the code. This method should be…
-
0
votes1
answer303
viewsHow to do a search with Join using Entity framework Lambda and Linq
How do I search two or more tables. In the system I am doing, I have the tables Barco, Tipodeoperacaodobarco and Classebarco My mapping is as follows: HasRequired(c => c.ClasseBarco) .WithMany(c…
-
0
votes1
answer54
viewsWhen the property is not int how to force Entity to create a field in the table as nullable:false
Migration is generating the name field in the table as nullable:true i don’t want it to be true, as I do to solve this problem? public class Professor { public string Id { get; set; } public string…
c# sql-server entity-framework asp.net-core entity-framework-coreasked 6 years ago Robson Junior 29 -
0
votes0
answers44
viewsUpdate data that has many to many relationship with Entity Framework
I’m trying to update an object and the only thing that doesn’t update is his relationship from many to many the rest as name and surname update [HttpPost] public IActionResult AtualizarProfessor(int…
-
0
votes1
answer362
viewsHow to customize Asp.Net Core 2.1 login screen
With the following service settings below I can login to Twitter, Hotmail, Facebook. Noting that my project at the time of creation enabled the individual login option services.AddAuthentication()…
-
0
votes1
answer37
viewsHow to configure the Incrementby of a Postgre Id field using the Entity Framework Core
I have a table mapped for Postgre, but when I update the database, the Personal Fieldphysicaenderecotipoid is being auto-incremented by 10 in 10 (by default). How do I map so that Incrementby is set…
entity-framework entity-framework-6 entity-framework-coreasked 5 years, 11 months ago Master JR 1,853 -
0
votes1
answer93
viewsPass list to model
I have a query that returns me a list this way: var list = db.Comentario.Where(d => d.GrupoTrabalhoId == Id).OrderByDescending(s => s.DataComentario).ToList(); After this query, she will…
-
0
votes0
answers68
viewsEntity Framework 6 catch attributes in Savechanges
I’m using the Entity Framework 6 with Oracle. The database is of a legacy system, I intend to set in hand the primary keys of the records. To make life easier, I want to take SaveChanges of…
-
0
votes0
answers14
viewsInvalidoperationexception: Unable to resolve service for type while attempting to Activate
This is probably a duplicate question, but all the questions I saw didn’t solve the problem. The mistake happening is: The flow is as follows: View -> Controller -> Service -> Repository…
c# entity-framework asp.net-core entity-framework-coreasked 5 years, 10 months ago Thiago Cunha 1,356 -
0
votes2
answers130
viewsI have Error in viewModel ASP.NET MVC C#
What I looked for, we used viewmodel to then access in the view several models, my problem is that I have an error that does not allow me to access the Model. And everywhere I look, I can’t figure…
-
0
votes1
answer63
viewsEntity Framework (Populating tables)
What is wrong with my project? When I try to give an Update-Database error message appears (The underlying provider failed on Open). When I remove the items I want to add, for example,…
-
0
votes2
answers65
viewsHow to do a parallelism or asynchronous call in a lambda
I have this query qry.ForEach(q => { var product = new Product(); product.CategoryId = q.CategoryId; product.AuthorizeMaximumPercentageAlteration = q.AuthorizeMaximumPercentageAlteration;…
-
0
votes1
answer281
viewsError while trying to popular a List
I’m trying to create a table with Union, I made a class to popular on ViewModel, in this way: public class ListVencimentos { public int Id { get; set; } public DateTime Data { get; set; } public…
-
0
votes1
answer100
viewsVirtual property is not instantiated in lambda
When I took a code to improve performance I had the following. A method GetAll() this method populated a var. It was made a foreach in this var and was assigning the appropriate values. It happens…
-
0
votes1
answer94
viewsProblem searching (Firstordefault) - Linq
I’m having a problem conducting the following search: var estDel = bdprincipalEntities.unidades .FirstOrDefault(x => x.uni_codigo == uni_codigo && x.Emp_codigo == Emp_codigo); the field…
-
0
votes0
answers24
viewsProblems in Mapping with Fluent
I already had a resale table, where I had to add a new field. This new field is a FK of a new table that I created. Then we have: Reseller(Reseller) which receives a FK Discount. In Reseller this…
-
0
votes0
answers86
viewsDisable Identity Entity Framework temporarily at runtime
I need to synchronize 2 databases, One stays on the local machine and one on the server, I get the data I need by Api via Json, And it returns me the model with the data I need to insert.. However…
-
0
votes0
answers30
viewsEF mapping with generic classes
I have a project that used Nhibernate with a generic/abstract class structure that was mapped without problems. the problem is that I was forced to migrate to Entity Framework and now I’m lost in…
-
0
votes2
answers759
viewsProblems connecting to sql server with Visual Studio and C#
I have encountered problems connecting to sql server by visual studio with Entity Framework 6. My connection worked normally and after I created a new project, I cannot access the database server.…
-
0
votes1
answer104
viewsEntity Framework Mapping - Area Code
I’m starting to work on a DDD project. I happen to be having a lot of doubts, and as much as I research, it gets more and more confused. I created this classe: public class Teste { public int Id {…
-
0
votes1
answer55
viewsLeft Join - Linq is bringing Duplicate Value
Hello, I have a print method, which makes several left join, it is bringing the values I want, but some of these values are coming duplicated, as shown in the images: Table TabelaImposto: select…
-
0
votes0
answers45
viewsCount number of Users
I have a Client class, and a Systems Class. A customer has one or more systems: public class ClienteEmpresa : Pessoa { public virtual ICollection<TipoDeSistemas> TipoDeSistemas { get; set; } }…
-
0
votes1
answer85
viewsError in Insert Entity Framekwork - Mysql
I am getting the following error while trying to perform Savechanges(): Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or…
-
0
votes0
answers44
viewsError 500 (Internal Server Error) Get
ERROR GET http://localhost:54446/Tasks/Listrintegrants? team=1 500 (Internal Server Error) HTML @using (Html.BeginForm()) { <div class="form-horizontal"> <h4>TarefaViewModel</h4>…
-
0
votes1
answer27
viewsData update issues with Entity Framework with relational data
I have a Query table that has two foreign keys (Client and Procedure). to add a new query I can normally, but when editing it does not change my Client or Procedure the other fields modifies…
-
0
votes1
answer50
viewsHow do I add the "same" object to a list and change a property?
I have to send a list of entitys to a method that will make the Insert of these entitys in the bank. This entity represents an inscription of a patient who will enter some waiting queues of…
-
0
votes0
answers453
viewsInvalidcastexception: Unable to cast Object of type 'System.Int32' to type 'System.Int64
I’m starting with Entity following this tutorial. My method is giving error in function at the time of Savechanges(); My Controller: [Route("api/[controller]")] [ApiController] public class…
-
0
votes1
answer1013
viewsSqlexception: The INSERT statement conflicted with the FOREIGN KEY constraint
I have a 1-n employee relationship. I used the Entity Migrations to create the tables based on my models. I checked in the database and the tables were created with their respective PK and FK.…
-
0
votes1
answer24
viewsLambda in related classes (EF Migrations)
It’s been a while since I’ve dealt with FE so I doubt it. Have the classes Product and Producthow much and need to make an inquiry in the products with quantity equal to 10; I tried to: var retorno…
-
0
votes1
answer68
viewsError trying to Edit PK and UK on ASP . NET Core
I would like to know how to manipulate the Unique Keys and Primary Keys with Entity Framework. Whenever I try to edit an attribute and pass the same value it had before, it returns me an error: "The…
asp.net entity-framework asp.net-core asp.net-identity entity-framework-coreasked 5 years, 5 months ago Snyp 13 -
0
votes0
answers312
viewsConverting a datetime2 data type into a datetime data type resulted in a value outside the range. The instruction has been completed
I have a class, a client who has a record date. public class ClienteViewModel: Pessoa { [ScaffoldColumn(false)] public DateTime? DataCancelamento { get; set; } [ScaffoldColumn(false)] public…
-
0
votes0
answers31
viewsNot pulling XML information
At the moment where I import XML information, it does not separate and play to the XML_List, for continuity to the code, it returns no value in that part of the code: XDocument xDoc =…