Top "Code-first" questions

Code-first is a software implementation approach that favors programming against an API over other approaches that may rely more heavily on visual tools or require the presence of some external source that is inspected to generate program behavior, structure, or data.

Column names in each table must be unique. Column name 'StripeRecipientId' in table 'dbo.Foos' is specified more than once

I have a model class named Foo that has, among others, these properties. public string StripeRecipientId { get; set; } public override …

entity-framework entity-framework-6 code-first
EF 4.1 Code First error - The entity type SomeType is not part of the model for the current context

While working with EF code first I get error given below at different times: The entity type SomeType is not …

entity-framework code-first entity-framework-4.1
EF6 CodeFirst My [Key] Id Column is not auto-incrementing as an identity column should

I have several classes that I need to derive from a common base class which holds an Id. Ignoring the …

c# sql entity-framework code-first on-duplicate-key
Entity Framework loading child collection with sort order

I have two tables a parent and a child table. The child table has a column sortorder (a numeric value). …

entity-framework ef-code-first poco code-first
Find a specified generic DbSet in a DbContext dynamically when I have an entity

I have following classes and DbContext: public class Order:BaseEntity { public Number {get; set;} } Product:BaseEntity; { public Name {get; set;} } …

c# entity-framework generics code-first dbset
How to run Seed() method of Configuration class of migrations

I have 2 questions: 1) How can I run Seed() method from the package-manager console without updating-database model? 2) Is there a way …

c# entity-framework code-first entity-framework-migrations
EF Code First Parent-Child insertions with identity columns

i have the following model. class Parent { int ParentId (identity column) { get; set; } string ParentName { get; set; } virtual ICollection<…

entity-framework code-first ef-code-first
EF 4.1 Code First: "non-null value of type 'DateTime'" Issue

After initial dev and testing I have now pointed my MVC3 application at an existing database which contains live data. …

asp.net-mvc entity-framework asp.net-mvc-3 code-first ef-code-first
Entity Framework Code First - No Detach() method on DbContext

I'm wondering why there is no Detach method on the DbContext object like there is for ObjectContext.  I can only …

entity-framework code-first
Entity Framework Database.SetInitializer simply not working

I am having this kind of "mysterious" issue here. I am currently using Entity Framework 4.1 Code First approach with my …

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