Most voted "fluent-api" questions
Entity Framework Fluent API, also known only as Fluent API, is an entity configuration feature present in the Entity Framework, used to define characteristics of an entity, its properties or the relationship between entities.
Learn more…63 questions
Sort by count of
-
10
votes1
answer398
viewsDoubt about mapping in Entity Framework 6. "readonly" properties
I have three tables in my bank: TB_COLABORADOR TB_JORNADA TB_JORNADA_COLABORADOR To TB_JORNADA_COLABORADOR makes the association of employees with the journey and vice versa through the fields…
-
8
votes3
answers1381
viewsWhat is the difference between Data Annotations and Fluent API?
What is the difference between Data Annotations and Fluent API? Is there a restriction between one or the other? Improve performance or are just two ways to do the same thing?
-
8
votes4
answers1003
viewsProblem saving a change using Entity Framework
I am trying to persist a change I make to a record but am getting this error: System.Invalidoperationexception: 'A referential Integrity Constraint Violation occurred: The Property value(s) of…
-
7
votes2
answers415
viewsFluent API with ASP.NET Identity
In accordance with this tutorial, I transported Identity in a class library to encapsulate the system’s business rule. However, the entire system is using Fluent API to map the entities and Identity…
-
7
votes1
answer129
viewsHow to map an image attribute by Fluent API?
I would like to know how to map an attribute of the type image of SqlServer by the Fluent API. In my bank I have the following table: CREATE TABLE [dbo].[ProdutoFotoERP]( [ProdutoFotoID] [int] NOT…
-
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…
-
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
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
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
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
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
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;…
-
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
votes2
answers1043
viewsASP.NET Identity and mapping Many to Many (Fluent API)
I recently created a Solution with the DDD architecture, putting ASP.NET Identity in a transverse layer (CrossCutting), I saw that many people use Identity this way and decided to try it. However, I…
-
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
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…
-
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
votes0
answers327
viewsEF mapping of Fluent API associative entity
I would like to know how to do a mapping without using ICollection, or may even be using, but would not want the bank to create a class, just to be able to connect the two classes. class Pessoa {…
-
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 {…
-
3
votes1
answer1291
viewsThe method or Operation is not implemented error
When I will add a record on my Include screen, I get this error. What can it be? Service public void AddItem(Test item) { var codigos = this.context.Tests.SingleOrDefault(x => x.Codigo ==…
-
3
votes1
answer1261
viewsInclude Method - MVC - working with data insertion in two tables
I have two classes: User User where Usuario possesses its id (PK) and UsuarioP owns the id (FK) of Usuario. I am working on ASP.NET MVC 4 using Fluent API. Classes are mapped within the project to…
-
3
votes1
answer32
viewsMigration Conventions
I have an MVC DDD application that uses Sqlserver. I’m trying to get the database to Postgressql, but there is a FK duplicity error. For example, the default Sqlserver would be generated:…
-
3
votes1
answer89
viewsConvert all strings to lowercase
There is a way to configure the modelBuider, to lower my strings? For example, when I want all my data of type string, be at my bank a varchar, i make the following configuration:…
-
3
votes2
answers343
viewsMany to Many with Fluent API
I’m doing a mapping with Fluent API and I came up with a question on how I should do the mapping very much. For example, I have the classes below. public partial class Territories { public…
-
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
answer321
viewsFluent Mapping or Data Annotations?
I was watching a video class on ASP.NET MVC, when I watch the Fluent Mapping of the Entity Framework for the first time. Then the doubt came to me. Which of the two is best recommended? Fluent…
-
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
answer31
viewsSettings Many to Many code fast Migration
good afternoon! I have this many configuration for many in my project. public class Usuario { public Usuario() { this.LocalTrabalho = new HashSet<LocalAtendimento>(); } public virtual…
-
2
votes2
answers426
viewsView Mapping with Entity Framework
I am doubtful how to map a View created in Oracle Bank 11G with Fluent-API. Here is an excerpt from the view with alias: tran.id_transporte AS "ID Navio", tran.ds_nome_transporte AS "Navio",…
c# database entity-framework-6 fluent-apiasked 6 years, 9 months ago Samuel Renan Gonçalves Vaz 720 -
1
votes1
answer87
viewsReplacement for the Fluent API
I am in a project of a system that uses the C#language, using MVC, Entity Framework and I am using the Fluent API. I wonder if there’s another way to do it. HasKey(oc => oc.OrdemCompraId);…
-
1
votes1
answer126
viewsFluent Mapping API 1:N cascateado
How to Model a Relationship of 1:N, where, 1 user may have several requests, and in this request we have reference to another entity? Ex: public class Usuario { public int UsuarioId { get; set; }…
-
1
votes2
answers411
viewsFluent API and Migration
I have the following scenario: public abstract class Pessoa { /* Propriedades do Pessoa*/ public Guid IdPessoa { get; set; } } public class Cliente : Pessoa { public Cliente() { IdPessoa =…
-
1
votes3
answers292
viewsEntity Framework 4 - Migrations error: The ... type is not defined in the <namespace> namespace. Map (Alias=Self)
I have a problem in mapping my application. [EDITED] Follows the Complete Datacontext Class: using System; using System.Collections.Generic; using System.Linq; using System.Web; using…
-
1
votes1
answer103
viewsASP.NET MVC How to Manipulate Table Users Using Code First
I’m studying MVC ASP.NET code first. I’m a beginner and I have a question probably basic. When starting a project, it already creates a basic application, including the table User. I happen to be…
-
1
votes1
answer87
viewsData Annotation - error ratio 1:1
I’m trying to make a 1-to-1 relationship. Apparently it would be something simple but my system is getting lost in this relationship; It doesn’t make a mistake, but the relationship is wrong: Model:…
-
1
votes2
answers121
viewsHow to format decimal numbers using Fluent API in the Entity Framework?
How to create a formatting with precision 10,4 (4 decimal places) to save decimal data to SQL Server? This format description goes inside the modelBuilder, however, I have not found any code already…
-
1
votes1
answer655
viewsMap relationships with Fluent API
I have three simple classes of city, state and country. I realized that simply declaring a property of the type Estado in class Cidade the foreign key is generated correctly. I would like to know…
-
1
votes0
answers208
viewsAutomapper error in relationship
I have the following classes: public class ListaGrupo : EntidadeBase { public ListaGrupo() { Items = new List<ListaGrupoItem>(); } public int Id { get; set; } public string Nome { get; set; }…
-
1
votes1
answer59
viewsFluent API modeling with reference table
I would like to know how I perform the modeling of a given entity, where its reference value belongs to another table. This benchmark would be a domain table that has your credit card id s, because…
-
1
votes1
answer688
viewsHow to set a string-like field to nullable in Code First?
I got the field descrPapel of the kind string and would like that field to be created as nullable, that is, to accept null when I was gonna do some Insert/update in records of this type of entity.…
-
1
votes1
answer366
viewsError in running update-database Migration
I am trying to run the creation of my database, but I am getting this error below and am not understanding the reason: The type 'Client' cannot be Mapped as defined because it maps inherited…
-
1
votes1
answer55
viewsRelationship of Fluentapi Tables
I am trying to make a relationship of tables, using Fluentapi with Entity Framework, in which my purpose are 3 entities: public class Empresa { public Empresa() { this.Gerentes = new…
-
1
votes1
answer120
viewsError inserting data with Entrityframework C#
I have a very strange problem, I have 3 tables, being them, Countries, States and Cities, all of them are configured certainly equal, but it is giving error only when it is inserted data in the…
-
1
votes3
answers160
viewsProblem mapping entities related to Fluent API
I am starting with EF and I am having problems to map the relationship between my entities. 1. Entities There are two entities in the project that I am using to practice the subject. They are: User…
-
1
votes0
answers28
viewsHow to solve the Stackoverflow exception that occurs in the Entity Map for the Model?
In my application a Team has several users and a User belongs to only one Team (1:N), so I have the following entities: public class Equipe{ public Guid EquipeId {get; set;} public string Nome {get;…
-
1
votes1
answer118
viewsMap a table and enable Auto-increment of a FK field in Postgre using EF Core and Fluent Api
I am unable to activate the Auto_increment of the Contactotype field in Postgre. In the table mapping I specified the "Valuegeneratedonadd" resource, but when I update the database with Migrations,…
entity-framework asp.net-core migrations fluent-api entity-framework-coreasked 6 years, 2 months ago Master JR 1,853 -
1
votes0
answers56
viewsError to map in Entityframework
Good, I’m trying to map a database using Entityframework-Reverse-POCO-Code-First-Generator and one of my views has the following mapping: public VIEW_CODE_NAV_CustomerLedgerEntryMapping(string…
-
1
votes1
answer30
viewsWhen defining which subpropriety in the EF mapping via Fluent API should be ignored, a Argumentexception is launched
I created a map on Entity Framework via Fluent API, however when defining that a subpropriety should be ignored the exception is thrown below: System.Argumentexception: 'The Expression 'x =>…
-
1
votes1
answer32
viewsCode First Generating a foreign key
I have the following classes public class ControleDeVisitas { public virtual ICollection<TipoDeSistemas> TipoDeSistemas { get; set; } } public class TipoDeSistemas { public Guid…
-
1
votes0
answers18
viewsError connecting to Entity Framework in an existing BD
I created an application that uses Entity Framework 6X and Code First mode by Fluent API, Map Classes, using classes from my model , and creating the context class. When I try to connect to see if…