Top "Ef-code-first" questions

EF Code-First is a way of using Microsoft's Entity Framework with POCO classes, as opposed to model-first or DB-first.

Code-first vs Model/Database-first

What are the pros & cons of using Entity Framework 4.1 Code-first over Model/Database-first with EDMX diagram? I'm trying to …

entity-framework ef-code-first entity-framework-4.1 poco ef-database-first
Entity Framework 6 Code first Default value

is there "elegant" way to give specific property a default value ? Maybe by DataAnnotations, something like : [DefaultValue("true")] public bool …

entity-framework ef-code-first default-value
Introducing FOREIGN KEY constraint may cause cycles or multiple cascade paths - why?

I've been wrestling with this for a while and can't quite figure out what's happening. I have a Card entity …

.net entity-framework foreign-keys ef-code-first entity-framework-4
The entity type <type> is not part of the model for the current context

I am getting into the Entity Framework, but I am unsure if I am missing a critical point in the …

c# entity-framework ef-code-first dbcontext
Ignoring a class property in Entity Framework 4.1 Code First

My understanding is that the [NotMapped] attribute is not available until EF 5 which is currently in CTP so we cannot …

c# .net entity-framework ef-code-first entity-framework-4.1
There is already an object named in the database

Update-Database failed from Package Manager Console. I've used Entity Framework 6.x and code-first approach. Error is "There is already an …

database entity-framework ef-code-first entity-framework-6 entity-framework-migrations
Unique Key constraints for multiple columns in Entity Framework

I'm using Entity Framework 5.0 Code First; public class Entity { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public string EntityId { get; set;} public int …

entity-framework ef-code-first constraints multiple-columns unique-key
How to fix the datetime2 out-of-range conversion error using DbContext and SetInitializer?

I'm using the DbContext and Code First APIs introduced with Entity Framework 4.1. The data model uses basic data types such …

c# .net entity-framework ef-code-first dbcontext
Decimal precision and scale in EF Code First

I'm experimenting with this code-first approach, but I'm find out now that a property of type System.Decimal gets mapped …

c# .net entity-framework ef-code-first decimal
How Should I Declare Foreign Key Relationships Using Code First Entity Framework (4.1) in MVC3?

I have been searching for resources on how to declare foreign key relationships and other constraints using code first EF 4.1 …

asp.net-mvc-3 ef-code-first entity-framework-4.1