What the purpose of OnModelCreating in EF4 Code-First?

前端 未结 2 575
刺人心
刺人心 2021-02-02 00:44

I was curious about what the purpose of OnModelCreating in EF4 Code-First context class? How does it work?

相关标签:
2条回答
  • 2021-02-02 00:47

    OnModelCreating gives you access to a ModelBuilder instance that you can use to configure/customize the model.

    As the previous answer mentions, you will typically use the code-first fluent API within it. Gil Fink has posted what IMHO is a clearer explanation than the article cited in the previous answer.

    For background info, Guthrie has a nice intro article on EF Code-First, and if you are wondering why its referred to as "fluent API", look here.

    0 讨论(0)
  • 2021-02-02 00:54

    Here is a nice article in ADO.NET Team Blog.
    In short, this event is mainly for Fluent mapping.

    0 讨论(0)
提交回复
热议问题