Questions tagged [ef-fluent-api]

A way to configure Entity Framework beyond its conventions with a method chaining API

Use the tag for questions that ask about:

  • Model-wide settings
  • Property mapping
  • Type mapping
  • Relationships

The EF-Fluent API can be used in both c# and VB.NET.

The MSDN documentation

833 questions
0
votes
1 answer

EF Fluent API creates duplicate tables

I have next entity configuration: public class OfficesContext : DbContext { public DbSet Offices { get; set; } public DbSet Expenses { get; set; } public DbSet ExpenseLogs { get; set; } protected…
Mardok
  • 624
  • 8
  • 18
0
votes
1 answer

Many to many relationships in Entity Framework 7 beta 8

Is there any way to do a many to many relationship (Fluent API or annotations) in EF7 beta 8 without create a join table?
0
votes
2 answers

Entity Framework Many-Too-Many Not Populating Results

I'm trying to map a many-too-many relationship in C# EF with code first migrations. The issue that I'm having is that no results are being populated from the related table. Take this piece of code for example, _role contains no permissions whereas…
Gareth
  • 5,140
  • 5
  • 42
  • 73
0
votes
1 answer

Rename foreign key column not working in fluent api

I am trying to make a self referencing table public class Category { // PK public int CategoryId { get; set; } // Property public string CategoryName { get; set; } // FK public int? ParentCategoryId { get; set; } …
Hao
  • 266
  • 1
  • 12
0
votes
1 answer

How to Create Custom Stored Procedures Using Code First Fluent API

There are many articles that show how to create Insert, Update, Delete procedures using Code First like this one. How about custom procedure like this simple select statement: Select * from Customers I could make changes to the Up and Down…
usefulBee
  • 9,250
  • 10
  • 51
  • 89
0
votes
1 answer

EF one-to-one relation not creates

I'll try create one-to-one relation using EF and Fluent API. First class: public class Game { public int Id { get; set; } public Guid Token { get; set; } public string Player { get; set; } public virtual Field Field { get; set; } …
beta-tank
  • 390
  • 1
  • 4
  • 17
0
votes
2 answers

Ignored property not returned in stored procedure

I have a blog model and a blog comment model. The blog has a collection of blog comments associated with it however when I'm getting all my blogs so that I can list them out on some sort of summary page, I don't want to be pulling all the comments…
Andy Furniss
  • 3,814
  • 6
  • 31
  • 56
0
votes
1 answer

EF Code-First User Testimonial System

I have a User entity in my DbContext. What I want is that users should be able to give references/leave comments for each other, therefore I have created Reference entity. public class Reference { public virtual User By { get; set; } // user who…
0
votes
0 answers

EF Code First Duplicate child relationships

I have a Person table that I want to be mapped to multiple foreign keys in a Usage table. Something like this: public class Usage{ int Id; int OwnerId; int CreatedBy; public virtual Person Owner; public virtual Person Creator; …
user441058
  • 1,188
  • 1
  • 16
  • 32
0
votes
1 answer

Entity Framework - Model Self-Referencing Dependencies Not Cascading Delete

I have a Group model/table: namespace Project { #region Usings using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; #endregion …
Ryan Mendoza
  • 920
  • 1
  • 13
  • 27
0
votes
0 answers

Neither data annotations nor fluent API are mapping my sql column to my Id in my object

I have the following class and DbContext. I've tried both data annotations and fluent api but both are somehow ignored and I get the exception listed below. What am I doing wrong? my class [Table("Users")] public class EFUser : IUser { //…
0
votes
0 answers

EF6 CodeFirst One to Many MySQL a foreign key constraint fails

I'm doing a Mapping from existing Database to CodeFirst and I'm having a problem with One To Many Relationships. System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for…
JuanDYB
  • 590
  • 3
  • 9
  • 23
0
votes
1 answer

Map Entity Relationships using Fluent APIs - Entity Framework

I have Following Entities in Application. Student Parent (This Parent can be Father/Guardian) Address They have following classes defined. public Class Student { public int StudentId {get; set;} //Addresses public Address…
0
votes
1 answer

connect tables with composite keys using code first fluent api

I have 2 entities: //Product (all properties is the composite key) public string Id {get; set;} public string CompanyName {get; set;} //ProductDescriptions (All properties is the composite key) public string ProductId {get;…
Daniel Gustafsson
  • 1,725
  • 7
  • 37
  • 78
0
votes
1 answer

Generating relationship in EF using single Key

I want to Map the relationships between my entities like this: public partial class Profile { [Key] public int ProfileId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string…
ECie
  • 1,265
  • 4
  • 21
  • 50