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
-
3
votes2
answers2574
viewsLINQ using function inside select new{} with lambda Expression
I am assembling a select, with the Entity Framework, which needs to "create a column" according to 4 criteria. I am trying this way: IQueryable<ImoveisDTO> Resultado = ctx.Imoveis.Select(ib…
-
3
votes2
answers234
viewsHow can I get the Insert in log with logged in user ? Identity - Asp.net core 2.0
I need to get the logged-in user to log in, thus including which user included in the table, made changes, and delete. I’m learning the language, and I still have many doubts. This is my…
asp.net-mvc entity-framework asp.net-core asp.net-identityasked 6 years, 4 months ago Mariana 2,512 -
3
votes1
answer50
viewsReturn text sql to model in the Entity framework
I have the parent class and the state class: [Table("tb_pais")] public class PaisModel { [Key] [Column("id")] public int Id { get; set; } [Column("nome")] [Required(ErrorMessage = "O campo nome é…
-
3
votes3
answers680
viewsHelp with Sqlquery in context Entity Framework
I need to make a return from my database in a specific way, but I have a problem, the situation is as follows: I have this query already tested directly on SQL Server, and is working perfectly:…
-
3
votes2
answers1074
viewsInner Join no entityframework
I need to do an Inner Join on Entity frameworkm in the bank, I can do normally this way: select * from Produtos inner join ProdutosEmpresas on ProdutoID = Produtos.Id But in the Entity framework I…
-
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
answer133
viewsDelete multiple database elements
I have a action [GET] delete on my Webapi. She removes one element, but would like it to remove all the elements that have a particular code. How can I change my code to remove all? My Code:…
-
3
votes1
answer145
viewsLeft Join with a table does not return null value
I have this select: var pesquisa = (from p in db.Produtos join pe in db.ProdutosEmpresas on p.Id equals pe.ProdutoID into peph from pe_ph in peph.DefaultIfEmpty() select new { p.Codigo, p.nome,…
-
3
votes1
answer33
viewsProblems with wpf Data Grid
Good night. I am developing a project but I am having problems, I use a list that is being generated with the data of my database (Entity for connection), I want to populate a data grid but I do not…
-
3
votes2
answers134
viewsEF Core - Pass parameter with integer list
I am trying to execute a query by passing as clause an 'in' with integers, this is the code so far: public List<Pedido> GetByUsuario(List<GestorVendedor> gestorVendedor) { int[]…
-
2
votes2
answers217
viewsForm in view with subforms in partialView
Dear friends, I have a view containing only @model Projeto.Models.Oc and a form. Within this form, I have buttons that call MODAL, those MODAL possess partialView who owns another form and @model…
-
2
votes2
answers1555
viewsCalling action with AJAX, but does not return Alert to view
In the textbox Ticket, at the event onChange() I call AJAX below: $('#Ticket').on('change', function () { var tkt = this.value; $.ajax({ url: '@Url.Action("VerificaTicket", "Oc")', data: { 'tkt':…
-
2
votes1
answer82
viewsHow to declare unique key fields with Entityframework?
Something that many seek but that there is no feature available in the versions of EntityFramework until the 6 is the use of unique keys (Unique Keys). There were even users asking how to create…
-
2
votes3
answers2078
viewsQuestions about relationship and mapping with Fluent API for EF 6
Whenever I have a class with properties that are of the type of other classes, which at the database level represents a foreign key, I will always need the navigation properties? And look at this…
-
2
votes1
answer1300
viewsCalculate date difference and compare with integer field in lambda expression
I have a data field (Datetime) and also an integer field. I need to make the difference between this date field and today’s date (Datetime.Now) and compare whether it is larger or smaller than my…
-
2
votes2
answers495
viewsLambda Expression X
Speaking in terms of overall performance (speed, integrity and etc...), using English expressions to query database, is better in the above terms or depends on?
-
2
votes1
answer244
viewsMulti-bank Login Control
Well, I have my application and every client will have his own database. As each customer will have their database, they will also have their user table for login. So I have Bancoempresa1 -…
-
2
votes2
answers173
viewsIs having two dbContext for the same Connection string considered bad practice?
I initially had a DbContext with all the DbSets of my entities. However, I needed to create a DbContext<T> who owns a DbSet generic for methods that are properly generic. It turns out that the…
-
2
votes1
answer85
viewsModel in sessions
I have a GRID (table) that when selecting an item through the ID I load the entity in a session via ajax. public static class Sessoes { public static Produto Produto { get { return…
-
2
votes1
answer324
viewsEntityexception when connecting to remote database
When connecting to the local bank, the application works 100%. However, when I try to connect to sql server remotely (on a redehost server), the application raises the following Exception: Below is…
-
2
votes1
answer197
viewsUpdate Entity framework version
I just upgraded my version of . Net 3.5 to 4.5.1. My Entity Framework was in version 3.5, I wanted to know if it already updates to the newer version after the exchange of framework.…
-
2
votes2
answers608
viewsUse of the Ienumerable
I saw an example in another post about the use of IEnumerable var ent = new EntFuncionarios(); IEnumerable<Funcionario> funcionario = ent.Funcionarios; IEnumerable<Funcionario> temp =…
-
2
votes1
answer167
viewsHow to search for the record when the table has a composite primary key?
I have in my database the table t_command_control. This table has a composite primary key formed by the fields CD_STATION and CD_COMMAND. If the primary key was simple (only as a field CD_STATION) i…
c# entity-framework linq linq-to-entities linq-to-sqlasked 9 years, 11 months ago Eduardo Freire Jr 21 -
2
votes1
answer412
viewsEntity framework with connection string via code
I am developing an application, and I need the connection string to be set in the code itself, because there can be no app.config file..
-
2
votes1
answer519
viewsHow to block editing of a record when it is edited by another C#user
In a network system (Several using the same database), how do I know if any user is already editing the record. Because if in case two computers edit the same record at the same time, a problem…
-
2
votes2
answers72
viewsExpression does not bring results, but there is data
This is my direct sql query. select c.de_cnpj, c.DT_TransacaoV from T_CRM_StatusPDV c join T_PDV p on c.DE_CNPJ = p.CNPJ where DATEDIFF(DAY,c.DT_TransacaoV,GETDATE()) > 45 This is my lambda…
-
2
votes2
answers510
viewsOptimize operation with lambda
I have the following classes: public class Pedidos_Itens { public int ID { get; set; } public int Qtde { get; set; } public Pedidos _Pedido { get; set; } public int Pedido { get; set; } public…
-
2
votes1
answer273
viewsExchange Entity Framework EDMX for Code First
I have an EF5 application using EDMX modeling and I have much more experience and affinity with Code First. Does anyone have any idea/tutorial on how to migrate from EDMX to Code First without…
-
2
votes1
answer1511
viewsComposite primary key with entities in the Entity Framework
I need to make a composite primary key relation in the Entity framework using the entities themselves. public class ProjetoDocumento { public Projeto Projeto { get; set; } public Documento Documento…
-
2
votes1
answer1122
viewsMake an SQL query with Entity Framework 4
How do I perform a query in the database using Entity Framework 4 passing a string previously stored inside a StringBuilder. The reason is that the SQL query string is giant. I know it is not a good…
-
2
votes1
answer42
viewsSqlserver 2012 - Column '' in table '' is of a type that is invalid for use as a key column in an index
After seeing this error when creating a NONCLUSTERED index I wondered if it would really be necessary to create this index in the following scenario: I have a table with 11 columns, a column I save…
sql-server entity-framework entity-framework-6 sql-server-2012asked 9 years, 6 months ago Ricardo 5,680 -
2
votes2
answers167
viewsManipulating related data Asp.net and C#
I am developing an ASP.NET application, which aims to register events and add customers to these registered events, forming a customer list for each event. My question is this: In the Events table…
-
2
votes1
answer506
viewsWrite Listview in SQL Database using Entity Framework and C#
I am developing a sales desktop application using C# and Entity Framework and I am having doubts about recording the items entered in ListView in the SQL database. How to save inserted items to…
-
2
votes1
answer526
viewsIqueryable select data from multiple tables
I have a queryable (Linq to entities) in the Entityframework and I’m not able to pull data from two or more tables. For example: var model = _service.List().Where(m =>…
-
2
votes1
answer123
viewsStored Proc X Entity - Is this a good decision?
On Entity Framework days, is doing an MVC project using Stored Procedure a good way forward? I have always heard this: If you opt for RU it makes no sense to use SP, but I have heard people say that…
-
2
votes1
answer677
viewsHow to do the mapping (Entitytypeconfiguration) of this complex type?
My application Numerators follow the 'secure enumerator' design pattern, where I have the enumerator statement as static members, and the Numerators instance following a contract (Ienumeradorseguro…
-
2
votes1
answer369
viewsOne-To-Many relation with explicit Foreign key name
I’m performing a simple mapping of one-to-Many via Fluent API specifying which column is used in the mapping, however EF "ignores" the configuration and continues using the name default. Mappings:…
-
2
votes1
answer40
viewsMysql Data Entities with Mysql Data 5.3.7
I wonder if there’s any way to use the MySQL.Data.Entities with the version of MySQL.Data 5.3.7. In the specification here speech that works with the MySQL.Data (6.4.4.0). Is there any other way to…
-
2
votes1
answer80
viewsFilter by group and minimum value
I have the following table: ********************************* * IdPessoa * DataVen * Observ * * 10000000 * 01/01/15 * Teste1 * * 10000001 * 01/01/15 * Teste2 * * 10000000 * 01/01/12 * Teste3 * *…
-
2
votes1
answer97
viewsQuery to SQL database in text saved by Tinymce
I am using Tinymce to edit texts on my website. When I search a word with accent. Ex.: análise, query does not find why the database is saved in HTML análise. I am using ASP.Net MVC with…
-
2
votes1
answer138
viewsHow NOT to cascade delete records with 1-n relationship using Entity Framework?
I have a table Menu that may have many Categories and these Categories may have only one Menu: public class Menu { public int Id { get; set; } public string Name { get; set; } public virtual…
-
2
votes1
answer97
viewsEntity Framework Extra column when using Icollection
If I have two tables in the bank, for example: tabela1 and tabela2, and in the tabela1 I have a ICollection of tabela2: public class tabela1{ public Guid tabela1Id {get;set;} //campos... public…
-
2
votes2
answers64
viewsWhy can’t I query for an added object before Savechanges?
I need to add several objects to the database and some objects need another specific object that I added earlier. When I make a query to get the object, it comes null. Example: var subItem = new…
-
2
votes1
answer158
viewsWhat is the correct way to declare the following class structure and get the respective Entityframework behavior?
I have the following class structure: public class Revenda { [InverseProperty("Revenda")] public virtual ICollection<UsuarioRevenda> Usuarios { get; set; } } public class Empresa {…
c# entity-framework pattern-design asp.net-identity entity-framework-6asked 10 years, 1 month ago user8052 -
2
votes1
answer109
viewsProperty containing only the Keyattribute attribute resulting in auto-increment column in the database
If I’m not mistaken, this must have come in version 6.1.1 of Entityframework and it wasn’t like this in previous versions. I believe a column only became auto-increment when the attribute…
-
2
votes2
answers146
viewsMapping a List<long> in LINQ to SQL - Windows Phone 7.1
Problem I’m starting an application for Windows Phone 7.1, and I’m implementing the database, only I came across a situation that I couldn’t find any example of similar situation to try to solve,…
-
2
votes2
answers1410
viewsRemove all records from a table with Entity framework 6
How to delete all data from a database table using EF6 without having to query (I want to delete all records)?
-
2
votes1
answer60
viewsIf there is update a table and insert into another, if not, insert into the two
How to make an expression using EPH so that when a certain list of objects is sent and already exists in the database, it is updated and the change is inserted in another historical entity,…
-
2
votes2
answers1154
viewsUsing distinct with Entity Framework
I have an object with a structure something like this: Date Description I’m thinking a distinct() in the description field because the records are ridiculously repeated. The question is, the…
-
2
votes1
answer69
viewsDoubt in the study of the Code First development approach
Galera I am studying the development approaches used in Entity Framework 6 the approaches Model First and Database First found good content easily on the internet and I was able to understand , but…