Questions tagged [ef-code-first-mapping]

Relating to using the fluent mapping API of Entity Framework Code first for configuring the SQL that gets generated on running migrations.

93 questions
0
votes
1 answer

Find entities not in many-to-many relation

I might be looking at this the wrong way but I have a basic many-to-many code-first setup in EF Core 3.1 with Department <-> DepartmentDay <-> Day. modelBuilder.Entity(entity => { entity.HasKey(dd => new { dd.DepartmentId,…
0
votes
1 answer

ASP.NET Core MVC code-first complex relation with enumerated value and index

I have a project where I need a complex relationship: public enum InputFileTypes { unknown = 0, ConfirmationFile = 1, PrestationFile = 2, EOCChoiceFile = 3, EOCReplaceFile = 4, CareStaffFile = 5, JobCreationFile = 6, …
0
votes
1 answer

CodeFirst EF Core - Implementing interfaces possible?

I'm a little new to code-first in EF Core and I'm trying a few things out and I'm a little confused how to implement the below (or indeed whether it can be implemented or not). In my model I have a class that maps entities to cases, with the…
0
votes
0 answers

EF Core Code first - relationship already being used

I'm still new to the .NET especially ef core. I am having trouble defining the relationship between the entities using code first approach with existing database. I develop this using Visual Studio Code and I can't do model first approach. I have 2…
wwdev
  • 13
  • 4
0
votes
0 answers

How to add relationships from the IdentityUser class in ASP.NET Core 3.1 Identity? (Code First)

I have a Asp.Net Core MVC 3.1 project. I want to join appointment and patient tables with code first technique however the foreign key column is null. My Patient Class; public class Patient : IdentityUser { [NotMapped] public…
0
votes
0 answers

Entity Framework MVC Code First BIND doesn't work for children entities inside EDIT action

I am using ASP Core Web Application, MVC, Code First, with MySQL db. Here is the structure of my db: Here is code for those 2 models/classes: =====This code is for 2nd EmployeeDate Table (Child)===== [Table("employeedate")] { [Key] …
0
votes
1 answer

Shopping cart models design with Microsoft Entity Framework Core

I am new to Entity Framework Core. In my shopping cart models design, I have a little confusion in designing my model classes using Entity Framework Core. I have assign collection of address to user model as multiple delivery address are possible…
0
votes
1 answer

EF Core navigation property without relations(foreign-key)

I have three classes public class Country { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public byte CountryID { get; set; } public byte OfficialLangID { get; set; } } public class Language { [Key,…
0
votes
1 answer

EF6 Table Splitting and exception "A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column: 'Id'."

For some time I've been following the "First Class Collections" rule from Object Calisthenics in my domain design. In order to avoid creating a useless "Collection" table though, I use the table splitting configuration from Entity Framework. But if…
0
votes
2 answers

How to define a navigation property via Entity Framework code first approach

I have the following class that I want to use as my data context in Entity Framework: public class AggregateRecord : IAggregateRecord { [Key] public int AggregateRecordID { get; set; } public DateTime? InsertDate {…
0
votes
1 answer

Mapping inheritance structure in Entity Framework Core to Postgres - Conflicting Error Messages

I have a number of inheritance hierarchies in my model. I'm using Entity Framework Core 3.1.2 with a Postgres database. Code First. I am trying to create a migration to generate my database tables. I mapped my first abstract object public…
0
votes
2 answers

Create one to many and many to one mapping between two tables in entity framework 6 code first approach

I want to create below two tables using Entity Framework 6 code first approach. I can use attribute notation or fluent API or combination of both. Mainly I want to know how to create the mappings between the two entities, so that the foreign keys…
0
votes
0 answers

I have one entity, i need to add property of entity type

**public class Ticket : BaseEntity { public TicketType TicketType { get; set; } } public class TicketType : AuxiliaryInfoBaseEntity { public string Description { get; set; } }** In Ticket Entity i need…
0
votes
1 answer

Same Table Many-To-Many Connection EF CodeFirst .net Core

Hi i have a model class like public class Individual : EntityBase { public Individual() { RelatedIndividuals = new HashSet(); } public string FirstName { get; set; } public string PersonalNumber…
0
votes
1 answer

IndexBuilder and ForNpgsqlHasComment

Why NpgsqlEntityTypeBuilderExtensions and NpgsqlPropertyBuilderExtensions has ForNpgsqlHasComment method to set Comment, but NpgsqlIndexBuilderExtensions doesn't. How to set Comment for Index in FluentApi?