Search This Blog

Monday, July 1, 2013

Entity frameworks notes

if you get such error while serialize your entity ".......System.Data.Entity.DynamicProxies is not expected."
after creating your entity context (generated class derived from DbContext) the next line:

 base.Configuration.ProxyCreationEnabled = false;

to solve the error of
DataContractJsonSerializer  "reference tracking is disabled" 
i remove some of my association i created to avoid back reference

Loading Related Entities -  http://msdn.microsoft.com/en-us/data/jj574232.aspx

links for EE framework
http://blogs.msdn.com/b/adonet/archive/2011/01/31/using-dbcontext-in-ef-feature-ctp5-part-6-loading-related-entities.aspx


To get the SQL query that generated by db entity use:
var sql = ((System.Data.Entity.Infrastructure.DbQuery<tbl_artists>)query).ToString();
if its object:
var sql = ((System.Data.Objects.ObjectQuery)result).ToTraceString();

Basic LINQ Query Operations (C#)



No comments: