IT:AD:Code First

Summary

Errata

ACiD

  • Advantages:
  • Considerations:
    • Can begin work with Entities before a Db even exists.
    • Deployment is a different story.
  • Considerations:
    • Deployment has to be carefully considered [Deployment]
  • Disadvantages:
    • I disagree, but still:
        • Notably the following comment: “One thing to consider is what you are wanting out of code first. Are you really going for defining your tables in code and having that create the database, or is it the POCO aspect of EF 4.3 that you want? The reason I ask is that you could use POCOs and DbContext with Database First or Model First (you can create a custom T4 to gen the POCOs from your model). The reason I ask is because I sometimes see people writing about “code first”, when the thing that they are really after working with POCO/DbContext.”

    ## Requirements ##

  • Requires EntityFramework 4.2 +
  • Install:
    • Install Nuget
    • from the Nuget Command Prompt
      • Install-Package EntityFramework

Relationships

Table Splitting

Querying

Transactions

FAQ

  • Does the target Db have to have an EdmMetaInfo table?
    • No: it depends on the Strategy. If the strategy is to not check/create/rebuild a Db, then it won't check the Db.

Essential Reading