EF - Code First Development Method

Overview:

   This section describes setting up a new database through Code First development .

   With Code First, you can choose to perform configuration using class attributes and properties, or using XML configuration files, or of course, using the Fluent API.

   Code First usage scenarios : How to use EF for projects that already have model typesCode First , also called POCO + Code Only .

   Code Only , as the name suggests, only requires code, not Edmx models .

   EF provides to generate SQL through type structure inference and create tables in the database, and can infer the relationship between entities through type members, developers only need to write entity classes to develop EF databases.

Pros and cons of Code First:

  Advantage:

     Simplifies development even further .

     Development efficiency is once again improved.

     The degree of automation is further improved.

     Can be applied to the original old project .

  Disadvantage:

     Performance is not very good.

     Few people know .

     The cost of learning is high, and the requirements for developers are relatively high .

Two ways to configure database mappings for Code First

   Code First has two ways to configure database mapping, one is using the data property DataAnnotation, and the other is using the Fluent API.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324878096&siteId=291194637