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
-
5
votes1
answer68
viewsComplex type can have Entity Type property?
I have a class Address that is Complex Type. She can own a state property that’s a Entity Type? Class code: public class Endereco { ... public string Logradouro { get; set; } public Estado Estado {…
-
5
votes2
answers200
viewsWhat’s the opposite of . equals in C#?
I’m doing a left Join where I want to pick up just what’s on the left table and there’s no right one. I’m using LINQ and Entityframework. I made a code that takes the similarities, follows below:…
-
5
votes3
answers727
viewsIs it bad practice to store CPF and CNPJ in the same column of the database?
In a flow that allows the registration of natural persons and legal persons I have seen the two approaches, but I’m not sure whether it is a good practice to store the two information in a column…
-
5
votes2
answers744
viewsDeletion of related data - Entity Framework and C#
Hello, Using the same structure that I have been presenting here for some time, I come to ask for help now to delete the related data. Follows the entities.. public class Artista { public int…
-
5
votes2
answers801
viewsKeep table records synchronized between two different databases
We are performing a system migration, where some restructurings will be done in the current bank in a new bank. Basically I will have two banks BancoVelho and BancoNovo, having to keep both of them…
asp.net-mvc asp.net sql-server entity-frameworkasked 8 years, 7 months ago Pablo Tondolo de Vargas 5,444 -
5
votes1
answer52
viewsWhat is the need to inform the parameter "Order" in the object of type Indexannotation?
I am creating indexes for some columns that will be used in a query with Where(). The intention is to make the search faster. Until then I was creating like this: Property(x => x.Documento)…
-
5
votes1
answer257
viewsEntity Framework Async Performance
I am implementing an asynchronous webapi, and have tested two ways to return the value with EF6. The 1st form was using Tolistasync(), and the 2nd form was using Task. The 2nd form has a much better…
-
5
votes1
answer270
viewsConsume entity repository directly from the application layer
I have a scenario where I need to search for a list of Active Employees with Entity Framework and display them on the screen (I need to convert to Dtos before displaying - what I do through the…
-
5
votes1
answer239
viewsHow to configure Entity Framework Mapping 1:N using inheritance
I have two classes: Pessoa and Usuario. The class Usuario inherits class properties and methods Pessoa. I am using the Entity Framework and I believe is doing the mapping wrong. That’s why the…
-
5
votes1
answer789
viewsUse Ienumerable or Icollection?
I want to create a 1 x N mapping using the Fluent API of Entity Framework, something like: a shopping cart has several products. In my class stroller, I have a navigation Property, which is a…
-
5
votes1
answer41
viewsEF6 - Rushed load bringing less aggregated data than database data
I’m having the following problem with my relationships in Entity. When I seek for example a Bank Account by Id : return _databaseContext.Clientes .Include(x => x.Enderecos) .Include(x =>…
-
5
votes1
answer437
viewsHow to work with CHAR-like Enums using C# and Entity Framework
I would like to know how to map my entity using an Enum of the type char by the Entity Framework, using Fluentapi. I have the following Enum: public enum Zona { Norte = 'N', Sul = 'S' } And my…
-
5
votes1
answer362
viewsWhat is the best validation strategy before data persists?
I’m used to . NET using C# and Entityframework. And there in the Entity we have the dataanotations. When I create the entity in C#, for example person, just put the datanotaations and the Entity…
-
5
votes1
answer147
viewsError doing UPDATE when setting varbinary variable as`null`
Follows code: var file = Request.Files; var list = new List<byte[]>(); for (int i = 0; i < 4; i++) { if (file.Count > i) { list.Add(ConvertTo.Bytes(file[i])); continue; } list.Add(null);…
-
5
votes1
answer101
viewsPersist data in related tables (1 x N)
I have these 2 related classes, and the requested class has a Collection of "Itenspedidos"... The Request class: public class PedidoDTO { public int pedidoID { get; set; } public int codigo { get;…
-
5
votes1
answer142
viewsDouble map the same entity
I’m trying to map the same entity twice into another public class Conveniado { public int Id { get; set; } public string Nome { get; set; }…
-
5
votes1
answer687
viewsHow to use the Foreign Key annotation in C#?
I am layman and would love to learn about. I will use in the example Model A and B not to get confused: I saw about the Model A take note Foreign Key in prop virtual Model B virModelB referencing a…
-
5
votes1
answer1690
viewsTolistasync() - Sqlnullvalueexception: Data is Null. This method or Property cannot be called on Null values
I’m getting the following error while trying to list all the records of a model: Sqlnullvalueexception: Data is Null. This method or Property cannot be called on Null values.…
-
4
votes2
answers747
viewsEF6 Code First Relation between entities
I am trying to create a Condominium data model in ASP.NET with SQL Server. I stumbled on the creation of the interface proprietario(1) with the fracao(many). The error returned is: The INSERT…
-
4
votes1
answer4398
viewsHow to configure Context not to put table name in plural?
I am in an ASP.net MVC 5 application, configuring a class DbContext. When the EF generates the database, the tables referring to the application objects are getting names in the plural. For example:…
-
4
votes2
answers442
viewsCode First with Complex Types, when making Scaffolding the properties of Complex Types are not found in the views
I’m following Sergey Barskiy’s presentation on http://www.youtube.com/watch?v=l3WzYZsN0gU, where it demonstrates the Entity Framework approach with Code First. I loved it, but I had a problem. In…
c# asp.net-mvc entity-framework code-firstasked 10 years, 9 months ago Guilherme de Jesus Santos 6,566 -
4
votes1
answer1034
viewsUpdate edmx from the bank
I did an update model from database on my edmx. Well, the field I had added in the table appears in the diagram, but in the entity’s Cs, it continues with the old fields. What do I do, add in hand?…
-
4
votes4
answers1399
viewsDatabases for different customers
I am learning MVC 4 and would like to know if there is a way with only 1 model access different databases? For example, I have an online system and for each customer I have a separate bank. What…
-
4
votes2
answers2690
viewsEF 6, Fluent Api mapping in inheritance classes
I am training in class mapping for the Entity Framework using the Fluent API and I have some questions. The first is as follows: Map a Foreign key with attributes would be like this: public int…
-
4
votes1
answer145
viewsHow to change the type of the persisted class in a legacy model using the Entityframework
I have the following class scheme with inheritance, as an example: public class Veiculo { public int Id { set; get; } public string Descricao { set; get; } } public class Moto : Veiculo { } public…
-
4
votes1
answer280
viewsC# Union/Order by with LINQ and Performance
Imagine the following situation there are 3 classes class A, class B, class C, class A has many classes B and many classes C. class B has many classes C. clsse C has a data datetime field. public…
-
4
votes2
answers363
viewsEF Relationship between 3 Tables
I am learning Entity Framework using Code First and found a difficulty with relationships. I have three tables in the system that I’m making: Flow (Key = ID_FLUXO); Step (Key = ID_PASSO); Acao (Key…
entity-frameworkasked 10 years, 6 months ago Rubens 115 -
4
votes4
answers1989
viewsUpdating data with Entity framework
In the project I’m developing, MVC5, Entity 6, I’m simply not being able to update the data. The Code: zyon.TB_Cliente.Attach(cliente); zyon.Entry(cliente).State =…
-
4
votes1
answer875
viewsEntity Framework auto relationship enable cascading delete
How to create a cascading deletion, in a self-relationship using the fluent api and enable this in entity framework? Code: Public class Usuario { public int UsuarioID { get; set; } public int?…
-
4
votes1
answer133
viewsError in database query with Linq
Good night! I am trying to perform a query in a mysql table, using English, and present this result in a gridview for the user. I have the table below: I’m not searching all columns of this table,…
-
4
votes1
answer350
viewsWhat’s the difference between using Savechanges() only once after adding data via a foreach and using inside the foreach?
I’m entering an average of 50,000 records into the database via the Entity Framework. And I got a question regarding the following code placements: in the first (1) placement, I use a foreach…
-
4
votes2
answers1819
viewsLogin using Entity with password encrypted as varbinary
I did the user password encryption and in the Password field of my table I went from Varchar to Varbinary, in the web part of my system it is all right only that in the windows part I am using the…
-
4
votes2
answers646
viewsIs it possible to work directly with Entityframework fonts?
It is possible to work directly with the Entity Framework and power "thresh" within their classes and methods? I downloaded the zip from his code Codeplex. I unpacked in a folder and in my project I…
-
4
votes1
answer162
viewsProblems with logic to bring data from a list or table
I did several posts here and solved almost all problems. However I understood that the problem was in the logic that I set up to bring the result. I know I’m asking a lot, but I’m trying and I…
-
4
votes1
answer394
viewsCode First Table Migration - N to N using Fluent API
I have the following classes: [Table("Area_Cursos_Turma")] public class Turma { public int TurmaID { get; set; } public virtual ICollection<Aluno> Alunos { get; set; } }…
-
4
votes2
answers83
viewsPersistence using Fluent API
How do I persist an address without having to pass on all customer information? Below is my address client mapping: HasMany(f => f.EnderecoList) .WithMany(e => e.ClienteList) .Map(me => {…
-
4
votes1
answer937
viewsEntity Framework attribute list for entity mapping
For my sake Database be outside the EF convention, and as another system already developed uses it, it is out of the question to change table/column names. I would like to know the available…
-
4
votes2
answers268
viewsQuery by Linq and Lambda getting options range by sub-query. How to get a result closer to simple?
Given the following classes: Menuraiz: public class MenuRaiz { public MenuRaiz() { Menus = new List<Menu>(); } [Key] [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set;…
-
4
votes2
answers5600
viewsThe underlying connection was closed: Unexpected error on a receipt
I have a web site that communicates with a WCF. This Wcf communicates with my "DAO" which is a Library class where I have the.edmx model for access to the bank. I referenced my DAO on WCF, and my…
-
4
votes1
answer391
viewsHow to return concrete classes, with populated navigation properties, through Linq queries?
Following that question: Query by Linq and Lambda getting range of options by sub-query. How to get a result closer to simple? where, however, my model grew to one more class (resulting in another…
-
4
votes1
answer1358
viewsCatch Penultimate record of a table with Entity Framework
How do I get the penultimate record from an Entity Framework table
-
4
votes2
answers2266
viewsPublish application with Entity Framework + Mysql
I’m using the Entity Framework for Mysql. I installed the .Net Connector, and the MySQL.Data.Entities. Locally it is working normally. But when I go up to the LocaWeb, will not. The following error…
-
4
votes2
answers849
viewsBest way to make class relationship
Hello, I would like to know what is the correct way to make relationship between classes of 1.. N and 1...1. Example: public class Pedido { public int PedidoID{get;set;} ............. } public class…
-
4
votes2
answers605
viewsField format for saving time
Which field should I use in SQL Server to save a duration? Ex.: 2days 23H 47min 00Sec. If you have an example with Fluent API it will help a lot.
-
4
votes1
answer62
viewsDoubt regarding good practices with virtual properties
I have a project that contains my classes that represent my entities in my BD. So, as an example goes there: On the table Endereco, I get a FK of Bairro(IdBairro). To play better in mine POCO, what…
-
4
votes4
answers188
viewsSQL Embedded in C#
I have a C# application that uses a Mysql database with Entity Framework. However, the size of the database is ridiculously small, so I don’t think it’s worth having a Mysql database server just to…
-
4
votes1
answer119
viewsHow do MVC application authentication with Linux?
I have a project in ASP.Net MVC and I’m putting the authentication manually. Everything is going well, but I used as a reference a ready-made project that uses the Entityframework, but I want to use…
-
4
votes1
answer109
viewsRandom Order with Entity Framework
I would like to translate the following SQL statement to an expression lambda: SELECT TOP 1 * FROM tbPessoa order by NEWID() What do I put in OrderBy that will be accepted? var pessoa =…
-
4
votes1
answer58
viewsDifference in EF exclusion forms
I want to know, what is the difference (if any) in the form of exclusion using the RU db.Contexto.Remove(objeto); db.SaveChanges(); And using the EntityState.Deleted; Db.Entry(objeto).State =…
-
4
votes1
answer193
viewsEntity Framework 6 tries to insert FK
I have a small application in C#, WPF and EF6. I’m using Code First, but I’m having a hard time creating a relationship. Look at my code, of the classes I want to relate: I’m editing for the final…