Here's a link to my new website showing how this can be done...
http://www.nigelfindlater.com/KnowHow/PublicKnowHow/3733
Saturday, 19 May 2012
Thursday, 3 May 2012
Some notes from Julie Lehrman on EF5 at the Inner Schweiz .Net User group
I visited a great talk by Julie Lehrman on Entity framework held at the Inner Scwiez .Net user group. Here is a brief summary. The next release of Entity framework EF5 builds upon EF4.5. What we know as the EF becomes the "Core" on top of this 2 new classes in a EntityFramework.dll. One of these classes is DbContext which surfaces a leaner API than the underling ObjectContext. The idea is that by having a lean API the funtionality will be discovorable via intellisense. In the current version of EF it is possible to cache queries, this avoids the overhead that is needed in generating the native sql when querying the database. In EF5 this becomes an automatic "auto cache" process. Another new feature is called Migrations that allows the code first approach to gracefully upgrade or down grade database versions.
The programming of CRUD DAL was easily made by inheriting from Dbcontect. The EntityFramework dll can be downloaded direct from NuGate. In Vs2010 the default databse is sqlexpress in vs2011 it is something else. If no database connection is provided a search is initiated for a database name corresponding to the name of the class that inherits from DBContext. If none is found then one will be created. The tables and properties are the created by code conventions and data annotations. These updates are made via a database initialisation, changes in versions are made via migrations with versioning being kept both via a special table in the database and in vs under the migrations file. There are various ways of seeding the database via DatabaseInitializer, Updgrading is made via Up() and downgrades via Down()
The talk also went through the basic nuts and bolts of EF and how to optimize performance, for example at the start of an application the reading of the edmx and the reflection of entities is an expensive operation. There are ways around this by making bounded entity context which makes it possible to give a subset of the POCO entities.
The programming of CRUD DAL was easily made by inheriting from Dbcontect. The EntityFramework dll can be downloaded direct from NuGate. In Vs2010 the default databse is sqlexpress in vs2011 it is something else. If no database connection is provided a search is initiated for a database name corresponding to the name of the class that inherits from DBContext. If none is found then one will be created. The tables and properties are the created by code conventions and data annotations. These updates are made via a database initialisation, changes in versions are made via migrations with versioning being kept both via a special table in the database and in vs under the migrations file. There are various ways of seeding the database via DatabaseInitializer, Updgrading is made via Up() and downgrades via Down()
The talk also went through the basic nuts and bolts of EF and how to optimize performance, for example at the start of an application the reading of the edmx and the reflection of entities is an expensive operation. There are ways around this by making bounded entity context which makes it possible to give a subset of the POCO entities.
Julie Lehrman contributes to online training at http://www.pluralsight-training.net/microsoft/Authors/Details?handle=julie-lerman
Subscribe to:
Posts (Atom)