Freigeben über


Updated Feature CTP Walkthrough: Code Only for Entity Framework

 


The information in this post is out of date.

Visit msdn.com/data/ef for the latest information on current and past releases of EF.

For Code First to a New Database see https://msdn.com/data/jj193542

For Code First to an Existing Database see https://msdn.com/data/jj200620


 

This post covers Code Only improvements in the CTP2 release for VS 2010 Beta2. This walkthrough shows how you can change the default model like specifying property facets and navigation property inverses as well change the default mapping by changing the default inheritance strategy and table and column names. You can learn more about the CTP2 Code-Only improvements from our blog post on the EFDesign blog.

Code Only ships as part of the Microsoft Entity Framework Feature CTP 2. The CTP works on top of the latest version of the Entity Framework released as part of .NET 4.0 Beta 2.

Requirements

  1. This walkthrough requires Visual Studio 2010 Beta 2
  2. The Microsoft Entity Framework Feature CTP2, that can be downloaded from here.
  3. A local SQL Server 2008 Express instance has to be installed as SQLEXPRESS.
  4. Download and extract the initial solution attached to this post.

Read More…

CodeOnlyWalkThru.zip

Comments

  • Anonymous
    January 12, 2010
    How can I use enums at property type? EntityConfiguration.Property dont accept enums

  • Anonymous
    January 13, 2010
    The comment has been removed

  • Anonymous
    February 02, 2010
    I am having a tough time working with navigation properties. It returns NULL always. i did enable lazy loading. The schema I have is very simple This is the Db Schema Customer with Id, Name Order with Id, orderNumber, CustomerId In the Model Customer = Id, CustomerName, List<Orders> Order = Id, OrderNumber, Customer, CustomerId The navigation properties are declared virtual I did the required mapping using entityConfiguration Here is configuration for Navigation properties only Order Relationship(o => o.Customer).FromProperty(c => c.Orders).HasConstraint((o, c) => o.CustomerId == c.CustomerId); Customer  Relationship<Order>(c => c.Orders).FromProperty(o => o.Customer); The navigation properties are always NULL. please suggest

  • Anonymous
    May 13, 2010
    here is the solution for your problem: http://stackoverflow.com/questions/2733254/how-do-i-map-a-composite-primary-key-in-entity-framework-4-code-first