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
-1
votes
1 answer

Directing context to use custom named join table for many to many entity relationship

I have 2 entities with a many to many relationship: [Table("Student", Schema = "School")] public class Student { public long ID { get; set; } public virtual List Teachers { get; set; } //... } …
-1
votes
1 answer

Unable to insert record into join/lookup/link table (EF/FluentAPI/MVC)

Alright so I'm a bit stuck at the moment. We've creating an MVC application using EF, fluent api, etc. and I'm having some trouble getting new records into a join table at the moment. DB Table…
makinitmine
  • 94
  • 2
  • 10
-2
votes
1 answer

How do you name a many-to-many relationship table using Fluent Api?

I have created a many-to-many relationship, and the name the table (the one that has the Id of both records / objects) has doesn't appeal to me. So how can I name that table using Fluent Api? By a usual table I'd use ToTable("Name"), but how do I do…
-2
votes
1 answer

ASP.NET Core Entity Framework get related data object

Every time I am trying to get a related object I get error Object reference not set to an instance of an object Relevant code: public class Project { public int ProjectId { get; set; } public string ProjName { get; set; } public…
Bing Han
  • 545
  • 1
  • 6
  • 10
-2
votes
1 answer

Fluent Api - Person and Creation

I have a problem.I have two classes that I use in Entity Framework. First one is a person Class: With int id, string name and action creation(incl. Foreign Key). Second one is a action class. With id , time and a person(incl. Foreign Key). When I…
-2
votes
1 answer

how can create Unique Constraint with multi column with entityframework

I'm use Entityframework Code First, and an EntityTypeConfiguration using fluent API. how can create Unique Constraint with multi column. for example i have a table with below field Id CompanyId Code Name i want set Code column to unique , per…
A.R
  • 3
  • 2
-3
votes
1 answer

how can i change table name by fluent API of entity framework code first in c#?

I want to change table name of my c# class by fluent API that it'll must be map on database (SQL Server), and I am using Entity Framework code first as ORM in my project.
-3
votes
2 answers

My database entity has a generic base BaseEntity, but how to map Id value of base entity to database entity?

How can I interchangeably use entity base Id or database column Id public partial class Orders : EntityBase { protected Orders() { } public int Orderid { get; set; } public override int Id { get => base.Id; set => base.Id =…
HydTechie
  • 797
  • 10
  • 17
1 2 3
55
56