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

Entity Framework 6 - Knowledge Base (KB)

58 results in tag: ef-fluent-api

Advantages and drawbacks of Fluent Api versus Data Annotations in Entity Framework

When creating a database using Entity Framework code-first, a lot of the database model is can be extracted from the code. Fluent API and/or Attributes can be used to fine tune the model....What are the advantages and disadvantages of Fluent Api in compar...
ef-fluent-api entity-framework
asked by Sam

Mapping to a database table that already exists

I am using ...Entity Framework 4.1 code first... to connect to an already existing database. The table that I am using first is called ...Bank.... I also have a ...Bank class... as my domain model. This is how I mapped my class and table:...public clas...
c# ef-code-first ef-fluent-api entity-framework
asked by Brendan Vogt

One to one relationship with Entity Framework Fluent API

I'm having trouble with reverse navigation on one of my entities. ...I have the following two objects:...public class Candidate { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public long CandidateId { get; set; } .... // Re...
c# ef-code-first ef-fluent-api entity-framework
asked by William

How to define Many-to-Many relationship through Fluent API Entity Framework?

Below is my model:...public class TMUrl { //many other properties //only property with type Keyword public List<Keyword> Keywords{get;set;} } public class Keyword { //many other properties //only property with type TMUrl public Li...
c# ef-fluent-api entity-framework many-to-many
asked by Manish Mishra

One to one optional relationship using Entity Framework Fluent API

We want to use one to one optional relationship using Entity Framework Code First. We have two entities....public class PIIUser { public int Id { get; set; } public int? LoyaltyUserDetailId { get; set; } public LoyaltyUserDetail LoyaltyUserDe...
c# ef-code-first ef-fluent-api entity-framework one-to-one
asked by İlkay İlknur

EntityFramework Code First FluentAPI DefaultValue in EF6.X

How can I set the default value using EntityFramework Code First FluentAPI for bool property?...Something like:...Property(l => l.PropertyFlag).HasColumnType("bit").DefaultValue(1);
c# ef-code-first ef-fluent-api entity-framework
asked by Tony Bao

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

Multiple indexes possible using HasColumnAnnotation?

It looks like in Entity Framework 6.1 they added the ability to create table indexes via the new ...HasColumnAnnotation... method. I created a few helper extensions to speed up the process:...public static class MappingExtensions { public static Strin...
c# ef-code-first ef-fluent-api entity-framework
asked by Sam

The declared type of navigation property Project.Models.Customer.SubCustomers is not compatible with the result of the specified navigation

I have had a look at answers to similar errors, but I can't seem to find an answer to my particular error....I am running a migration and the error happens when the seed method is run (migration has worked fine)....The declared type of navigation property...
c# ef-code-first ef-fluent-api ef-migrations entity-framework-6
asked by tekiegirl

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

One or Zero to One Entity Framework Code First FluentApi

I need to create fluentapi one or zero to one reference and have navigation properties on both of entities. ...EntityTwo should contain simple proerty to store foreign key (EntityOneId)...public class EntityOne { public int Id { get; set; } public...
c# ef-code-first ef-fluent-api entity-framework
asked by Oleg Gochachko

Set a constraint for minimum int value

I am using the Repository pattern. I have a entity called Product and I want to set the minimum value for price to avoid zero prices. Is it possible to create it in a EntitytypeConfiguration class?...My product configuration class... public class ProductC...
c# ef-code-first ef-fluent-api entity-framework
asked by Rodrigão

Entity Framework Code first: cycles or multiple cascade paths

I have a Booking class that has a booking contact (a ...Person...) and a set of navigation properties (...People...) that links through a join table to another set of navigation properties (...Bookings...) in ...Person.... How do I generate the ...Booking...
c# ef-fluent-api entity-framework sql-server
asked by James Peters

Mapping object type property to varbinary(MAX) in Entity Framework

I have a situation where I have a type with a property of type ...object..., eg....public class MyType { public virtual object MyProp{get; get;} } ...This type will have to be:...Saved using ...Entity Framework... to a database, as a ...byte[]... (I ha...
c# ef-fluent-api entity-framework wcf
asked by user919426

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

Violation of primary key Entity Framework Code First

I have started with C# and I wanted to make my own DB....I have two models...public class AModel { public Guid ID { get; private set; } public string Name { get; set; } public int Count { get; set; } public AModel() { this.ID ...
c# ef-fluent-api entity-framework
asked by Tomas Bruckner

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

Page 1 of 3
  • 1
  • 2
  • 3
  • »

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
Save your entities 20× faster with EF Extensions
SaveChanges vs BulkSaveChanges

EF Extensions
Try for free now
Get monthly updates by subscribing to our newsletter!
SUBSCRIBE!