zoukankan      html  css  js  c++  java
  • Entity Framework Code-First(2):What is Code-First?

    What is Code-First?:

    Entity Framework introduced Code-First approach from Entity Framework 4.1. Code-First is mainly useful in Domain Driven Design. With the Code-First approach, you can focus on the domain design and start creating classes as per your domain requirement rather than design your database first and then create the classes which match your database design. Code-First APIs will create the database on the fly based on your entity classes and configuration.

    code-first in entity framework

    As a developer, you first start by writing C# or VB.net classes and context class. When you run the application, Code First APIs will create the new database (if it does not exist yet) and map your classes with the database using default code-first conventions. You can also configure your domain classes to override default conventions to map with database tables using DataAnnotation attributes or fluent API.

    The basic workflow would be:

    Write application domain classes and context class→ configure domain classes for additional mapping requirements → Hit F5 to run the application → Code First API creates new database or map existing database with domain classes → Seed default/test data into the database → Finally launches the application

    Let's see simple code first example in the next chapter.

  • 相关阅读:
    C# String 与 byte 互转
    ajax 传值 中文乱码问题
    Js 日期处理
    sqlCacheDependency 更新缓存Cache
    SQL分割字符串,返回临时表
    E:could not get lock /var/lib/dpkg/lock -ope
    YAML-CPP
    [gazebo-1] process has died [pid 22855, exit code 255,
    gperftools对程序进行分析
    pclConfig.cmake or PCLConfig.cmake
  • 原文地址:https://www.cnblogs.com/purplefox2008/p/5643995.html
Copyright © 2011-2022 走看看