EF 4.1 Code First - OnModelCreating call time

前端 未结 3 555
一向
一向 2020-12-19 02:40

When I debug my application this method seems not to be executing in constructor context of DbContext. So when it is called then?

3条回答
  •  误落风尘
    2020-12-19 03:35

    OnModelCreating triggers when EF4 is creating the database. Usually this event is used to configure the way EF4 generates the database, so if you executed your application before and your model remains the same, the database is already there and EF4 does not try to generate a new one (although this behaviour also depends on some configuration parameters).

提交回复
热议问题