As a database, you will always be aware of the number of requests and statements. This is related to many performance issues.
So if you're using EF, you're likely to get a bad request if you don't understand the principle.
So, the basic thing before you get to know EF is that you have to "see" What kind of SQL statements EF generates for us, and how many times it accesses SQL
In fact, there are a lot of good tools to achieve these things, but I lazy to find to try, so I found a simple and reluctantly can use.
This is a log of Microsoft itself.
Reference:
Http://msdn.microsoft.com/en-us/data/jj556606-Logging Database Operations to a File (EF6.1 onwards)
In our web config plus this interceptors
<entityFramework> <defaultconnectionfactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/> <providers> <provider invariantname="MySql.Data.MySqlClient"Type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"/> <provider invariantname="System.Data.SqlClient"Type="System.Data.Entity.SqlServer.SqlProviderServices, Entityframework.sqlserver"/> </providers> <interceptors> <interceptor type="System.Data.Entity.Infrastructure.Interception.DatabaseLogger, EntityFramework"> <parameters> <parameter value="D:\vs2014\ProjectLearn\entitysix\EFLog\LogOutput.txt"/> <!--specify where you want to save the file to--<parameter value="false"Type="System.Boolean"/> <!--false means that each time the app is restarted, it "won't" erase the previous one, true--</parameters> </interceptor> </interceptors> ;</entityframework>
After running, you can view the
Opened connection at the/9/ - -: +: the+ ,:xxSELECT ' Extent2 '. ' id ', ' Extent2 '. ' Code ', ' Extent2 '. ' Name ' from ' Prod_category_vs_prod ' as ' Extent1 ' INNER JOIN ' prod ' As ' Extent2 ' on ' Extent1 '. ' prod_category_id '=' Extent2 '. ' id ' WHERE ' Extent1 '. ' prod_id '=@EntityKeyValue1--EntityKeyValue1:'2'(Type = Int32, isnullable =false)--Executing at the/9/ - -: +: the+ ,:xx--Completedinch -ms with result:efmysqldatareaderclosed connection at the/9/ - -: +: the+ ,:xx
That's probably it.
If you have a better use with easy to install, please let me know! Thank ^^
Entity Framework with MySQL learning Note one (view EF and SQL Entry)