tagged [code-first]
How to make Fluent API configuration work with MVC client side validation?
How to make Fluent API configuration work with MVC client side validation? I prefer working with Fluent API configuration to DataAnnotation because I want to separate model from data access. I have tr...
- Modified
- 17 Jan at 12:10
what is the most reasonable way to find out if entity is attached to dbContext or not?
what is the most reasonable way to find out if entity is attached to dbContext or not? when i try to attach entity to context i get an exception > An object with the same key already exists in the Ob...
- Modified
- 17 May at 15:39
Mapping composite keys using EF code first
Mapping composite keys using EF code first Sql server table: How should I map this in EF 6 code first? I've seen some examples where you have to set the order for each column, is that required? Is
- Modified
- 15 Feb at 18:26
EF CodeFirst: Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong
EF CodeFirst: Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong I've a table named `EducationTypes` and an Entity named `EducationType`, I renamed one of entity prop...
- Modified
- 13 Feb at 07:21
Exclude a field/property from the database with Entity Framework 4 & Code-First
Exclude a field/property from the database with Entity Framework 4 & Code-First I will like to know that is there a way to exclude some fields from the database? For eg: ``` public class Employee { ...
- Modified
- 4 Oct at 10:0
Which part of this relationship WillCascadeOnDelete(true)?
Which part of this relationship WillCascadeOnDelete(true)? This is what I have today: What I would like is to have the related `DealDevice` rows be deleted if the user is deleted so that I can just de...
- Modified
- 5 Jun at 22:18
Does EF Core allow a unique column to contain multiple nulls?
Does EF Core allow a unique column to contain multiple nulls? My entity has a property which is allowed to be null. BUT, if it isn't null, then it must be unique. In other words, the column is unique ...
- Modified
- 3 Jan at 08:39
AsNoTracking using LINQ Query syntax instead of Method syntax
AsNoTracking using LINQ Query syntax instead of Method syntax I'm interested in using `AsNoTracking` with my LINQ select queries to improve performance. I'm using Entity Framework 5 with Code First. H...
- Modified
- 5 May at 14:58
EF Code First prevent property mapping with Fluent API
EF Code First prevent property mapping with Fluent API I have a class `Product` and a complex type `AddressDetails` Is it possible to preve
- Modified
- 28 Feb at 08:30
Using DbContext Set<T>() instead of exposing on the context
Using DbContext Set() instead of exposing on the context Are there any differences when doing the following: versus using the `Set` method of the context: These effectively do the same
- Modified
- 4 Dec at 20:57
Implementing Zero Or One to Zero Or One relationship in EF Code first by Fluent API
Implementing Zero Or One to Zero Or One relationship in EF Code first by Fluent API I have two POCO classes: ``` public class Quotation { public int Id { get; set; } public virtual Order Order { g...
- Modified
- 20 Sep at 10:9
Entity Framework Code First Using One column as Primary Key and another as Auto Increment Column
Entity Framework Code First Using One column as Primary Key and another as Auto Increment Column I have a class named And in the database, I want
- Modified
- 30 Jan at 20:13
EntityFramework CodeFirst: CASCADE DELETE for same table many-to-many relationship
EntityFramework CodeFirst: CASCADE DELETE for same table many-to-many relationship I have an entry removal problem with the EntityFramework and a many-to-many relationship for the same entity. Conside...
- Modified
- 18 Sep at 16:15
EF Code First - how to set identity seed?
EF Code First - how to set identity seed? I have a entity class I have set the Id field as the primary key with auto number generation ``` modelBuilder.Entity().HasKey(e => e.Id); modelBuilder.Entity(...
- Modified
- 12 May at 07:24
Id of newly added Entity before SaveChanges()
Id of newly added Entity before SaveChanges() I am adding an entity to my database like so: However, the `DbSet.Add` method isn't returning the newly added entity with the Id etc, it is simply returni...
- Modified
- 17 May at 10:46
Entity Framework CodeFirst many to many relationship with additional information
Entity Framework CodeFirst many to many relationship with additional information I have the following model : the problem is that the relationship between Part and Contract also contains the following...
- Modified
- 25 Mar at 14:58
EF 6.1 Unique Nullable Index
EF 6.1 Unique Nullable Index In EF 6.1 using Code First you can create Indexes using Attributes in your Entities or using the fluent API along the lines of: ``` Property(x => x.PropertyName) ....
- Modified
- 23 May at 12:18
Delete table from EF CodeFirst migration
Delete table from EF CodeFirst migration In EF Code first, I want to drop one column from one table & then delete another table. After removing one column from class file, automatically one migration ...
- Modified
- 14 Aug at 05:46
How do I set a column in SQL Server to varchar(max) using ASP.net EF Codefirst Data Annotations?
How do I set a column in SQL Server to varchar(max) using ASP.net EF Codefirst Data Annotations? I've been searching around the web trying to figure out the right syntax to have Entity Framework Code ...
- Modified
- 28 Jun at 06:17
Why does Add-Migration sometimes create duplicate migrations?
Why does Add-Migration sometimes create duplicate migrations? I am facing a weird problem with code first migrations in Entity Framework version 5. Sometimes `Update-Database` fails due to pending cha...
- Modified
- 5 Oct at 11:7
conversion of a datetime2 data type to a datetime data type error with EF Code first?
conversion of a datetime2 data type to a datetime data type error with EF Code first? I'm using EF Code first with my asp.net mvc application. here is my code: the type of RequestDate is datetime in m...
- Modified
- 25 Jan at 14:49
Create a DbSet<T> dynamically in Entity Framework?
Create a DbSet dynamically in Entity Framework? In LINQ to SQL, I can create a repository dynamically using `DataContext.GetTable`. Is there a similar way to do this in Entity Framework 4 other than d...
- Modified
- 1 Dec at 16:49
Unique Key constraints for multiple columns in Entity Framework
Unique Key constraints for multiple columns in Entity Framework I'm using Entity Framework 5.0 Code First; I want to make the combination between `FirstColumn` and `SecondColumn`
- Modified
- 17 Feb at 14:50
How to declare one to one relationship using Entity Framework 4 Code First (POCO)
How to declare one to one relationship using Entity Framework 4 Code First (POCO) How to declare a one to one relationship using Entity Framework 4 Code First (POCO)? I found [this question (one-to-on...
- Modified
- 23 May at 10:31
Entity Framework - How to check if table exists?
Entity Framework - How to check if table exists? I'm using the Entity Framework with Code First approach. The base class DbContext has functions to create and delete the database as well as to check f...
- Modified
- 23 May at 18:8