What is Code First (EF Code First series), codeef

Source: Internet
Author: User
Tags in domain

What is Code First (EF Code First series), codeef

Code First is supported in EF4.1. This method is very useful in domain design patterns. With the Code First mode, you can focus on Domain Design and create a class set for your objects in a domain as needed, instead of designing the database First, and then designing your class based on the database, code-First APis will create a database for you based on your class and configuration.

As a developer, you first write C # Or VB.. NET class and context class. When you run the program, Code-First ApIs will create a database (if this database does not exist), and then use the default conventions, map your class to the database. Of course, you can configure your domain class to override the default convention and map the database. Here you can use the data Annotation Feature and Fluent API.

The basic workflow is:

First, write the domain class and context class ---> Configure the ing conditions for the domain class -----> click F5 to run the program ----> Code -- First APIs to create a new database, you can also map the domain class to an existing database ----> set to add the test data to the database ----> finally run the program.

In the next section, let's look at a simple Code-First example.

 

 

Attached series directory:

  • What is Code First?
  • Simple Code First example
  • Code-First Convention
  • DB Initialization (Database Initialization)
  • Inheritance Strategy (Inheritance Policy)
  • Configure Domain Classes (configuration Domain class)
  • DataAnnotations (Data annotation)
  • Fluent API
  • Configure One-to-One (Configure a One-to-One relationship)
  • Configure One-to-multiple (Configure One-to-multiple relationships)
  • Configure allow-to-Configure (Configure Many-to-Many relationships)
  • Move deployments (data migration)
  • DB Initialization Strategy (Database Initialization Policy)

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.