Entity Framework with MySQL learning Note one (view EF and SQL Entry)

Source: Internet
Author: User

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&gt ;</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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.