Friday, June 3, 2011

EF Code-First in the shape of NHibernate - Data Context (2/5)


Context in EF are the same as Sessions in Nhibernate. It's very expensive to create and once it's been created we have to watch it till it's been disposed.


Context in EF can be configured simply by inherit from DbContext(System.Data.Entity). You can also inject your ConnectionString  into the context before it's been constructed. Once any ConnectionString mentioned, EF gets its configuration from local SQLExpress on your machine. 


There is only one method that should be overridden when using this approach, OnModelCreating. This method is responsible to go through all mapping classes (next post on the series) and create schema that a database engine needs.




On the next post, I am going through the details of DocumentMap, DocumentDetailMap.

FA |-| I M

No comments:

Post a Comment