zzz projects Entity Framework Core EF Core
Home Articles Knowledge Base Online Examples
  • Home
  • Articles
  • Knowledge Base
  • Online Examples

Entity Framework Core - Knowledge Base (KB)

96 results in tag: ef-fluent-api

Foreign key issues in EF6 CF

Excuse me for being a noob with EF when it comes to code first. My problem is I don't want to add foreign key properties to the model and according to MSDN this presents no problem using the fluent API, however I can not figure out the correct use for my ...
c# ef-code-first ef-fluent-api entity-framework entity-framework-6
asked by weagle08

Setting unique Constraint with fluent API?

I'm trying to build an EF Entity with Code First, and an ...EntityTypeConfiguration... using fluent API. creating primary keys is easy but not so with a Unique Constraint. I was seeing old posts that suggested executing native SQL commands for this, but t...
c# ef-fluent-api entity-framework entity-framework-6
asked by kob490

Entity Framework Code First Fluent API configuration for one to one identifying relationship

I have the following class structure:...How to configure Fluent API to put identifying relationship in Cards table? ...I mean ...Cards Table PK: Id, CustomerId...Cards Table FK: CustomerId...I would like the previous Card be deleted when I assign a new on...
c# code-first ef-fluent-api entity-framework entity-framework-6
asked by Dmitry Nogin

Optional One-to-many Relationship in Entity Framework

I'm having issues getting an optional one-to-many relationship to work....My model is:...public class Person { public int Identifier { get; set; } ... public virtual Department Department { get; set; } } public class Department { public i...
c# ef-fluent-api entity-framework entity-framework-6
asked by givemelight

How to create Lookup table and define relationships

As you can see at below, there are a Lookup table for the enum values and I want to create a relationship between a table's enum values and ...LookupKey... column of the Lookup table (instead of ID column of the Lookup table). ...Lookup table:...ID | Lo...
asp.net-mvc ef-fluent-api entity-framework entity-framework-6 entity-relationship
asked by Jack

How to add an index on multiple columns with ASC/DESC sort using the Fluent API?

I have a MVC ASP.NET application using Entity Framework 6 - Code First approach. ...Using the Fluent API, how can I add an index on multiple columns with ASC/DESC sort that is different for each column ?...I've seen many examples using multiple columns b...
ef-code-first ef-fluent-api entity-framework entity-framework-6 indexing
asked by Maxime

Entity Framework 6 NotMapped attributes

Is there a way using the fluentAPI within a DbContext to manually include ICollections that have been [NotMapped] in the model? I know how to manually ignore properties using the fluentAPI ...modelBuilder.Entity<MyEntity>().Ignore(e => e.MyChildCollection...
ef-fluent-api entity-framework entity-framework-6 fluent
asked by Ted

Create one to one relationship optional on both sides in EF6

Is there a way to map two entities to have one to one relationship optional on both sides using fluent API in Entity Framework 6?...Code example...:...// Subscription (has FK OrderId) this.HasOptional(t => t.Order) .WithOptionalDependent(t => t.Subscr...
ef-fluent-api entity-framework entity-framework-6
asked by Filipe Borges

Code First Entity Framework 6: 1 to 1 with composite key

I've inherited a legacy SQL database that I am attempting to reverse engineer into Code First. Changing schema is not an option due to legacy software running on current config. What's strange to me is the developer configured the child table to have a co...
ef-code-first ef-fluent-api entity-framework entity-framework-6
asked by Steve Greene

EF 6 Codefirst -Setting default value for a property defined in base class using fluent API

I have a base class which has audit properties like...public abstract class BaseModel { [Column(Order = 1)] public long Id { get; set; } public long CreatedBy { get; set; } public DateTime CreatedDate { get; set; } public long Modifie...
ef-fluent-api entity-framework entity-framework-6
asked by Abi P

Entity Framework 6 Code First VarBinary Length in mapping or computed column

I see it is possible to use a query to find a length of a varbinary field in a query....Entity framework and VARBINARY...But can you map a FileSize property to get the size of a varbinary in the Fluent API without having to write queries?...I want to be a...
code-first ef-fluent-api entity-framework entity-framework-6 sql-server
asked by Andez

Entity Framework 7 Fluent API Doesn't Recognize IsOptional()

I'm currently setting up my database in my Asp.Net 5 project using entity framework 7, previously with EF 6, when I wanted to make some of my columns nullable, I would use:...modelBuilder.Entity<Article>().Property(t => t.ArticleDateModified).IsOptional()...
ef-fluent-api entity-framework entity-framework-core
asked by Hamid Mosalla

Defining Self Referencing Foreign-Key-Relationship Using Entity Framework 7 Code First

I have an ...ArticleComment... entity as you can see below:...public class ArticleComment { public int ArticleCommentId { get; set; } public int? ArticleCommentParentId { get; set; } //[ForeignKey("ArticleCommentParentId")] public virtua...
ef-fluent-api entity-framework-core
asked by Hamid Mosalla

Entity Framework 7 trouble creating migration because navigation property with the same name exists

I'm trying to create my first migration using Entity Framework 7 with code first development and I'm getting the following error:...The property 'Email' cannot be added to the entity type 'UserDTO' because a navigation property with the same name alread...
c# ef-code-first ef-fluent-api entity-framework-core
asked by Josh R

One-to-One relationships in Entity Framework 7 Code First

How to configure One-to-One or ZeroOrOne-to-One relationships in Entity Framework 7 Code First using Data Annotations or Fluent Api?
ef-code-first ef-fluent-api entity-framework entity-framework-core
asked by Ruben Perez

Entity Framework 7: Identifying relationships

In previous versions of EF I can use following code to implement an identifying relationship:...public class Child { [Key, Column(Order = 1)] public virtual int Id { get; set; } [Key, Column(Order = 2)] public virtual int ParentId { get; ...
c# ef-fluent-api entity-framework entity-framework-core
asked by double_a

Entity Framework Foreign Key Mapping

I'm trying to determine what EF6 is telling me, and it's not making much sense to me, so I'm hoping someone here can clarify this....I'm setting up my FluentApi as so (composite keys in use in the DB, this is Code First from Database):...modelBuilder.Enti...
c# ef-fluent-api entity-framework entity-framework-6
asked by John

Entity Framework 6 creates Id column even though other primary key is defined

I defined a DataObject as:...public class SensorType : EntityData { //PKs public string CompanyId { get; set; } public string ServiceId { get; set; } public string Type { get; set; } } ...And used fluent API to make CompanyId and ServiceI...
c# data-annotations ef-fluent-api entity-framework entity-framework-6
asked by Emil Nyborg

Mapping inheritance in EntityFramework Core

I'm using EntityFramework Core, Code First and Fluent Api to define model database, and i've follow situation about strategy of map inheritance:...public class Person { public int Id { get; set; } public string Name { get; set; } } public class U...
design-patterns ef-fluent-api entity-framework entity-framework-core orm
asked by Tainer Poletto

System.Data.Entity.ModelConfiguration missing in EF core

Trying to load all the configurations dynamically on OnModelCreating for Entity framework core. what is the other way around if ModelConfiguration is missing.
.net-core ef-fluent-api entity-framework-core
asked by Kenny

Page 1 of 5
  • 1
  • 2
  • 3
  • 4
  • 5
  • ยป

Prime Library

Performance

  • Entity Framework Extensions
  • Entity Framework Classic
  • Bulk Operations
  • Dapper Plus

Expression Evaluator

  • C# Eval Expression
  • SQL Eval Function
More Projects...

Related

  • EF Extensions Online Benchmark
  • WIN an EF Extensions license
  • EF6 BatchSaveChanges for only $79
Get monthly updates by subscribing to our newsletter!
SUBSCRIBE!