What the purpose of OnModelCreating in EF4 Code-First?
问题 I was curious about what the purpose of OnModelCreating in EF4 Code-First context class? How does it work? 回答1: Here is a nice article in ADO.NET Team Blog. In short, this event is mainly for Fluent mapping. 回答2: 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