Most voted "entity-framework-6" questions
It is a set of ADO . NET technologies that supports data-driven application development.
Learn more…371 questions
Sort by count of
-
4
votes1
answer288
viewsCreate unique attribute beyond Primary Key in code-first
I’m creating a table of Logradouro where the countryside CEP is not the primary key, but should be unique. How do I do it using code-first in the Entity 6.0? To create primary key I use the method…
-
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
votes1
answer114
viewsTime Usage with EF 6
I have a class with the following property. public TimeSpan TempoIdeal { get; set; } Estou atribuindo esta propriedade com TempoIdeal = new TimeSpan(days: 3, hours: 15, minutes:10, seconds: 0);…
-
4
votes1
answer39
viewsHow to set default properties for variables that start with specific text?
Is there any way to define the properties of a variable as default by the initials of the variables? Something like public string obsUsuario { get; set; }, all of which start with Obs by default the…
-
4
votes1
answer90
viewsbring menus and active submenus C#
I have to make a query through the menu I have to bring only the active submenus, see my code. return context.Set<Menu>().Include("MenuGroups") .Where(x => x.Id == id &&…
-
4
votes1
answer954
viewsHow to create a foreign key in a table where data already exists, in Entityframework with Code-First?
I have a system already in production of which the client requested a modification. The modification is the creation of an EMPLOYEES table that will relate to the MOVEMENT table, creating a 1:N…
-
4
votes1
answer272
viewsHow to create default filters with Entity framework 6?
I have an Excluded field in several classes and when I will make my select I always have to impose this condition in the query, is there any way to make the filter implicitly? recalling that it is…
-
4
votes2
answers88
viewsWhat is the Creation proxy for in the Entity framework?
What is the purpose of disabling this feature?
-
4
votes1
answer116
views'System.Stackoverflowexception' When running Migration with Dbmigrator
I have my Migration that has a number close to 6500 records like this: db.MinhaLista.AddOrUpdate(x => x.Codigo, (new MeuModel { Codigo = "ABC1234", Nome = "Teste "})); However while running my…
-
4
votes1
answer235
viewsUpdating collections with Entity framework
It is possible to update the Collection of an entity with one-to-many through his navigation property? public class Foo { public virtual IList<Bar> Bars {get; set;} public int FooID { get;…
-
4
votes1
answer2169
viewsBest practices when filtering a query with Entityframework
I have a web api method that receives a model from a search form and according to its values, it starts to filter the result of this search, as an example below. public HttpResponseMessage…
-
4
votes1
answer302
viewsProblem with left Join using Entity framework
I’m having a problem performing a left Join on Asp.net mvc. I own a view that lists all screens of the system, the same are registered in the database. I created a table of type (tab), screen and…
-
4
votes1
answer167
viewsProblem returning items in a Relationship in the Entity Framework
Talk Personal All right!? I’m going through the following problem in the Entity framework that I think is some mistake I’m making when it comes to relating two classes: I have a Class called:…
-
4
votes2
answers3123
viewsError saving Datetime type field
I am mounting an example of Code First, but when saving a field of type Datetime in the database returns me the following error Conversion of a datetime2 data type into a datetime data type resulted…
-
4
votes1
answer65
viewsEntity Framework - Object exclusion with relationship
I have a question to understand the behavior of Entity. Because when I pass null Entity should not "clean up" the relationship in the bank? My Model: public partial class Ocorrencia { [Key] public…
-
4
votes1
answer219
viewsQuery Return - Generic Entity Framework Repository
I have a generic repository and I realized that it is taking too long to return a query with the selection of some columns of my database, the Query() method is as follows: public IList<T>…
-
4
votes1
answer318
viewsEntity Framework is not interpreting my settings
I have a serious problem with Entity Framework. I have two tables: Módulos and Viaturas, both with primary key name ID (Database First). A car can have a Module, but it can also be null, the…
-
4
votes2
answers176
viewsDoing a LINQ function that can be called in an EF query
I have the following expression: Where(cd => cd.Modal == modal) .Select(s => s.Volume) .DefaultIfEmpty(0) .Sum() what use to make a same calculation several times within a few querys through…
-
4
votes1
answer54
viewsExpression generation for EF with dynamic properties
I’d like to conduct a search on where for Entity Framework passing the name of the property you would like to compare as a string. For example, I have the following classes: public class ClientData…
-
3
votes1
answer849
viewsHow to disable Migrations from an EF6 project?
Hello! I have a class library with models using Code First and enabled Migrations with the command "enable-Migrations" in PMC to test and works very well. As I am at the beginning of the model…
-
3
votes1
answer68
viewsEntityframework 6 - Load Model and its dependencies in Home
I have a college project where I decided to do a blog. Something very simple, author, post and comments. only these three. Well First I wanted to home of the project he carried the Posts (Articles)…
-
3
votes1
answer411
viewsHow to get the specific type of error returned by the Entityframework?
Following the question: How to intercept exceptions when working with the Entity Framework? Is it possible to get any error type identifier? For example, Primary Key Violation, Foreign Key…
-
3
votes1
answer943
viewsMVC 5 and EF 6 Putting Form from another view
Keeps giving comment error null in this line: ViewBag.PostId = new SelectList(db.Posts, "PostId", "Titulo", comentario.PostId); Probably why you didn’t sing in the ModelState.IsValid. I’m doing a…
-
3
votes1
answer4108
viewsDoubts about column formatting in gridView
Hi, I have some questions about formatting the columns in a gridview, I have a gridView that is populated by data coming from a table in the database, the columns and row are generated…
-
3
votes3
answers109
viewsHow to test Entity Framework performance?
I want to create mapping with heritage Person -> Customers, etc But I would like to test performance with the 3 types of mapping( TPH,TPT,TPC) How do I do it? Someone has had the experience to…
-
3
votes2
answers149
viewsInclude Entityframework
I am working with Entity Framework 6, I have made all the necessary settings. I have a Class Person that owns a Property of the Address Type, within address I have a property Municipality that…
-
3
votes1
answer836
viewsMapping one-to-Many entity with Fluent API
I have two classes, as an example below: public class Foo { public virtual int Chave {get; set;} public virtual List<Bar> Bar {get; set;} } public class Bar { public virtual int Chave {get;…
-
3
votes1
answer226
viewsWhy are relationships in the Entity Framework code first pointed with Icollection<T>?
Why are relationships in the Entity Framework code first pointed to with Icollection? What is the best instantiation(?) for the property in common cases? List? Using the virtual keyword is only to…
-
3
votes1
answer383
viewsError in relation statement 1 to 1 in EF with code-first and attributes!
I have the following classes where I want to make a relationship 1 to 1: User: [Table("Usuario")] public class Usuario { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id {…
-
3
votes1
answer1373
viewsProblem returning Entity models: "The Entity or Complex type ... cannot be constructed in a LINQ to Entities query"
I’m trying to return a list of objects generated by the Entity Framework Database First but I get this error: The Entity or Complex type 'leaosites04Model.TB_LEMBRETES' cannot be constructed in a…
c# entity-framework linq entity-framework-6 linq-to-entitiesasked 10 years, 5 months ago Reynaldo 141 -
3
votes1
answer793
viewsLambda Linq Problem: LINQ to Entities does not recognize... get_Item(Int32). How to resolve?
When trying to execute the loop for (time when query is executed) is giving error in my lambda expression: var funcionarios = repository.Funcionarios .Include(x => x.Cargo) .Include(x =>…
-
3
votes1
answer294
viewsWhat is the purpose of the Onmodelcreating method and how does it work?
I am studying Fluent API and I am with this doubt, I saw that this method can be empty, without any implementation. So what is its usefulness and how the Onmodelcreating method works that is in the…
entity-framework-6asked 9 years, 2 months ago Kelly Soares 1,181 -
3
votes3
answers2912
viewsSelect in Entity framework with certain columns
I’m trying to make a select in a table that contains several columns and I want the command sql that the Entityframework gera contain only the columns I specified. My code is like this: var clientes…
entity-framework-6asked 10 years, 2 months ago Rod 9,412 -
3
votes1
answer151
viewsEntity Framework - N to N, clear list
public class Aluno { public int AlunoID { get; set; } public virtual ICollection<Turma> Turmas { get; set; } } public class Turma { public int TurmaID { get; set; } public virtual…
-
3
votes1
answer59
viewsIs the query generated by the Entity Framework valid for use in ADO?
I’m wanting to have a higher performance in a query I perform in the system Consequently use ADO is much faster than Entity Framework To query that it generates when performing the query, could be…
-
3
votes1
answer108
viewsProperty of a class that belongs to another context in the Entity Framework
I have a class called Locker that has the following property : public virtual ICollection<LockerReserve> Reserves { get; set; } The problem is that Lockerreserve belongs to a different context…
-
3
votes1
answer824
viewsAudit with Entity Framework
I am wanting to do the audit tables of my entities. At first I thought to overwrite the method SaveChanges. I also thought of writing a method that will be doing the audit on my repository base.…
-
3
votes1
answer158
viewsMultitenancy with Entity Framework
I have my application, which shares the same database with all my customers. Separating them only by a column of the table Empresa_Id, all my actions, Save, List, Edit, Delete are done by my…
-
3
votes2
answers222
viewsEntity Framework and parameterized constructor
When I create domains, I usually create a parameterized constructor for the same: namespace Models { public class Unity { public string Abreviation { get; set; } public string Description { get;…
-
3
votes2
answers5090
viewsError localhost Visual Studio
My VS was working perfectly, today I bought and installed the antivirus Kaspersky, when I went to run a site ASP.NET (MVC) the following error appeared: UNABLE TO START PROGRAM 'An operation is not…
asp.net asp.net-mvc-5 visual-studio entity-framework-6 localhostasked 7 years, 9 months ago Jefferson Souza 379 -
3
votes3
answers1531
viewsValidate field after typing in ASP.NET MVC
I have a registration page in ASP.NET MVC with Entity Framework, this registration has an indication field, where the nickname of the user that indicated. I wanted after typing this field by the…
asp.net-mvc asp.net asp.net-mvc-5 entity-framework-6asked 7 years, 9 months ago Alisson Marqui 1,128 -
3
votes2
answers70
viewsHow to use Contains without capitalization and minuscule
Follows the code: var result= db.Table.Where(l => l.Field== value).ToList(); var search = "jOãO pAuLo"; result = result.Where(l => l.Example.Contains(search)).ToList(); Only works that way:…
-
3
votes1
answer226
viewsHow to force an Exception when trying to delete a Master record that already contains relationship in a Child Record?
I created the following structure in SQL Server: Using Entityframework with Code-First the classes stayed that way: [Table("Master")] public class Master { [Key]…
c# sql-server entity-framework entity-framework-6 relationshipasked 9 years, 8 months ago Severo 299 -
3
votes1
answer791
viewsproblem with update Entity Framework 6
This is my method of updating: public dynamic Atualizar(TEntity obj) { dynamic data = null; using (ClassContexto ctx = new ClassContexto(ClassMaster.conexao())) { try { ctx.Entry(obj).State =…
-
3
votes2
answers868
viewsHow does Entityframework’s Tracking / Chache work?
Every time I used the Entityframework in a project, to add a record in the database through it, of a class that contains class type members (usually on account of Foreignkeys), I would do this:…
-
3
votes1
answer425
viewsEF6 Entityvalidationerrors error in filled property
I have a similar problem in two ASP.NET applications with Entity Framework. When I try to update an entity that already has all the required attributes filled I get an exception from…
c# mvc entity-framework-6 validation model-validationasked 9 years, 6 months ago Eduardo Barbosa Oliveira da Si 45 -
3
votes2
answers705
viewsError while deleting using Entity Framework 6 and custom repository
I am using the Entity framework to do CRUD in the database, but I have an error trying to delete an item: "The Object cannot be Deleted because it was not found in the Objectstatemanager." I’m using…
-
3
votes1
answer1027
viewsCode First Migrations Mysql - Specify the '-Verbose' flag to view the SQL statements being Applied to the target database
I am creating a web application in C# and because of the hosting server, the database is in Mysql. Then I installed Mysql.Data.Entity, EF6, enabled Migrations, added the Migrations class, but when…
-
3
votes1
answer245
viewsException when generating Controller with Entity Framework
In my application using Asp.net mvc, with Entity Framework 6, with Mysql, when trying to add the Controllers, with Views, using EPH, I have the following error: Settings of my web config.:…
asp.net-mvc asp.net-mvc-5 entity-framework entity-framework-6asked 9 years, 3 months ago Erico Souza 2,188 -
3
votes1
answer357
viewsFluent Nxn mapping of Classes with composite key
I have two classes that have composite primary keys, example: Cliente: public class Cliente { public int EscritorioId { get; set; } public virtual Escritorio Escritorio { get; set; } public int Id {…