Entity Framework 4

I had the privilege of doing the first presentation for the C# SIG the other night.  The presentation was the second part of a presentation I did for them last month on Entity Framework 4.  The intent of this presentation was to cover the fundamentals of Entity Framework and show my fellow devs how easy it is to get started using Entity Framework.  Along the way, I attempted to mentioned common and best practices used in the field and gotchas to avoid.  You can download the sample code and presentation here. Entity Presentation Files

See the comments section of this post for my follow-up answers to questions I received from the group last night.

– Rich

One thought on “Entity Framework 4

  1. Below are the questions I was asked by the group.

    Q: Does EF provide an option for a Command Timeout?
    A: Yes. The ObjectContext.CommandTimeout Property Gets or sets the timeout value, in seconds, for all object context operations. A null value indicates that the default value of the underlying provider will be used.
    http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.commandtimeout.aspx

    Q: Issues with EF Connection to db?
    A: I was not able to find anything showing issues with EF connections to the db, however, I did find this document on how connections can be managed in EF. By default, Object Services manages the connection to the database. It opens connections only when required, for example to execute a query or to call SaveChanges. Object Services then closes the connection when the operation is complete.
    http://msdn.microsoft.com/en-us/library/bb738582.aspx

    Q: Does EF support multiple transactions to the database?
    A: Yes.The Entity Framework supports automatic transaction enlistment. This means that activities performed within an object context, such as executing queries and saving changes to data in the data source, can be isolated in the data source by executing the operation within a System.Transactions transaction.
    Transactions are used in the Entity Framework to do the following actions:
    – To execute multiple operations against the data source that must be highly consistent, such as queries that depend on
    the successful completion of object changes.
    – To coordinate changes in the object context with other distributed operations, such as sending an e-mail notification
    or writing to a message queue.
    http://msdn.microsoft.com/en-us/library/bb896325.aspx

    Q: Can EF return multiple result sets from a storedprocedure?
    A: Willem Meints did a great job answering this one http://blogs.infosupport.com/blogs/willemm/archive/2010/07/16/ado-net-entity-framework-advanced-scenarios-working-with-stored-procedures-that-return-multiple-resultsets.aspx

    EF Power Tools CTP1. I mentioned this during the POCO/Related Entities Section. The EF Power tool is focused on Code First Development and has an option to Reverse Engineer your Database, which in turn will create clean POCO objects (unlike those created by T4 Templates). You can download it here http://blogs.msdn.com/b/adonet/archive/2011/05/18/ef-power-tools-ctp1-released.aspx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s