Quantcast
Channel: entityframework Discussions Rss Feed
Viewing all 1793 articles
Browse latest View live

New Post: EF RC1 much slower than previous version

$
0
0
Don't worry about sharing the performance report, I've collected enough data to analyze the issue. One more question though: are you using migrations, or a non-default database initializer?

Thanks,

David.

New Post: EF RC1 much slower than previous version

$
0
0
I'm using migrations, but not automatic.

I have a very large seed method, but it is not being called during startup. In SQL Profiler, I can see queries against the migrations table, but it is after the slow part.

Thanks.

Diego

New Post: EF RC1 much slower than previous version

$
0
0
Are you calling Database.SetInitializer<[YourContextClass]>(null) before you create your context for the first time in the application? If not, can you add that line as an exercise and see if the regression persists?

David.

New Post: EF RC1 much slower than previous version

$
0
0
I have identified a possible source for the regression you observed. Can you share the performance report with me? You can email me to daobando at you-know-where dot com.

Thanks!

David.

New Post: EF Power Tools Consolidation/Release

New Post: EF Power Tools Consolidation/Release

$
0
0
PowerTools are not integrated with the EF6 designer at the moment. Since it did not fit in the release we are thinking about updating PowerTools so that they work with EF6 until the inegration with EF6 Designer is complete.

New Post: EF Power Tools Consolidation/Release

$
0
0
Thanks much - in that my SO thread already has a downvote (presumably as it's not code related?) permit this followup re: your reference to EF6 Designer. Would this be fair statement:

Up to this point Power Tools have provided a non-GUI interface to some of the code-gen features (reverse engineer from existing db) of EF for developers using the Code First approach. 'Coming Soon' is some sort of GUI for Code First.

if so, has such a creature been previewed/overviewed anywhere already?

thnks again

New Post: Why is EF so useless !?? (compared to Linq2SQL)


New Post: How to get generated SQL queries from DbContext

New Post: EF6, code first, relationships and multiple data contexts

$
0
0
I started using EF6 RC1 (code first) as I wanted to develop using different data contexts. This simplifies development management, allows different developers to work on contexts separately and also allows us to either us a single SQL database or assign each context to a separate database.

One of the key requirements was to create relationships between entities in different contexts. We have run into a problem with this in that the migration files are creating new copies of the tables on the referring context. This could be either:
Does anyone have any thoughts or suggestions on this? Thanks

New Post: EF Power Tools Consolidation/Release

$
0
0
@justSteve - I think it is OK. What we are thinking about is extending reverse engineering capabilities that already exist for Database First approach in a way that they could also be used to create CodeFirst models from existing database.

You can find a high level overview here.

Thanks,
Pawel

New Post: How can I use multiples DbContext(Mapping Error) - Module Application EF6

$
0
0
What can I do to get an feedback from you guys?


Thank you so much.

New Post: EF6 RC1 returning different queries from EF5, but slower and degrading performance.

$
0
0
Hi. We have experimenting an issue with SQL Azure when using EF6 RC1. Our problem happened last Monday and we are working with MS SQL Azure team to identify what is going wrong.

Our last changed was an update from Entity Framework 5 to EF6, and we realize that some simple queries are doing Index Scan while the same command using EF5 is doing Index Seek.

Please, Take a look:

EF5 query:

exec sp_executesql N'SELECT
[Limit1].[IdUser] AS [IdUser],
[Limit1].[MobileCode] AS [MobileCode],
[Limit1].[MobileSession] AS [MobileSession],
[Limit1].[Name] AS [Name],
[Limit1].[Email] AS [Email],
[Limit1].[IdCountry] AS [IdCountry],
[Limit1].[Password] AS [Password],
[Limit1].[PasswordSalt] AS [PasswordSalt],
[Limit1].[Sex] AS [Sex],
[Limit1].[Birthday] AS [Birthday],
[Limit1].[TelephoneNumber] AS [TelephoneNumber],
[Limit1].[CellphoneNumber] AS [CellphoneNumber],
[Limit1].[Cep] AS [Cep],
[Limit1].[AcceptNewsletter] AS [AcceptNewsletter],
[Limit1].[DateCreated] AS [DateCreated],
[Limit1].[LastUpdate] AS [LastUpdate],
[Limit1].[IdAddress] AS [IdAddress],
[Limit1].[IdDocument1] AS [IdDocument],
[Limit1].[IdDiscountApproval] AS [IdDiscountApproval],
[Limit1].[IsEmailValid] AS [IsEmailValid],
[Limit1].[TimeLimitConfirm] AS [TimeLimitConfirm],
[Limit1].[FacebookId] AS [FacebookId],
[Limit1].[TwitterId] AS [TwitterId],
[Limit1].[OnFacebookCreated] AS [OnFacebookCreated],
[Limit1].[OnTwitterCreated] AS [OnTwitterCreated],
[Extent3].[IdDocument] AS [IdDocument1],
[Extent3].[IdDocumentType] AS [IdDocumentType],
[Extent3].[Document] AS [Document]
FROM (SELECT TOP (1) [Extent1].[IdUser] AS [IdUser], [Extent1].[MobileCode] AS [MobileCode], [Extent1].[MobileSession] AS [MobileSession], [Extent1].[Name] AS [Name], [Extent1].[Email] AS [Email], [Extent1].[IdCountry] AS [IdCountry], [Extent1].[Password] AS [Password], [Extent1].[PasswordSalt] AS [PasswordSalt], [Extent1].[Sex] AS [Sex], [Extent1].[Birthday] AS [Birthday], [Extent1].[TelephoneNumber] AS [TelephoneNumber], [Extent1].[CellphoneNumber] AS [CellphoneNumber], [Extent1].[Cep] AS [Cep], [Extent1].[AcceptNewsletter] AS [AcceptNewsletter], [Extent1].[DateCreated] AS [DateCreated], [Extent1].[LastUpdate] AS [LastUpdate], [Extent1].[IdAddress] AS [IdAddress], [Extent1].[IdDocument] AS [IdDocument1], [Extent1].[IdDiscountApproval] AS [IdDiscountApproval], [Extent1].[IsEmailValid] AS [IsEmailValid], [Extent1].[TimeLimitConfirm] AS [TimeLimitConfirm], [Extent1].[FacebookId] AS [FacebookId], [Extent1].[TwitterId] AS [TwitterId], [Extent1].[OnFacebookCreated] AS [OnFacebookCreated], [Extent1].[OnTwitterCreated] AS [OnTwitterCreated]
FROM  [dbo].[User] AS [Extent1]
INNER JOIN [dbo].[Document] AS [Extent2] ON [Extent1].[IdDocument] = [Extent2].[IdDocument]
WHERE [Extent2].[Document] = @p__linq__0 ) AS [Limit1]
LEFT OUTER JOIN [dbo].[Document] AS [Extent3] ON [Limit1].[IdDocument1] = [Extent3].[IdDocument]',N'@p__linq__0 nvarchar(max) ',@p__linq__0=N'01420276506'

and EF 6 query:

exec sp_executesql N'SELECT
[Limit1].[IdUser] AS [IdUser], 
[Limit1].[MobileCode] AS [MobileCode], 
[Limit1].[MobileSession] AS [MobileSession], 
[Limit1].[Name] AS [Name], 
[Limit1].[Email] AS [Email], 
[Limit1].[IdCountry] AS [IdCountry], 
[Limit1].[Password] AS [Password], 
[Limit1].[PasswordSalt] AS [PasswordSalt], 
[Limit1].[Sex] AS [Sex], 
[Limit1].[Birthday] AS [Birthday], 
[Limit1].[TelephoneNumber] AS [TelephoneNumber], 
[Limit1].[CellphoneNumber] AS [CellphoneNumber], 
[Limit1].[Cep] AS [Cep], 
[Limit1].[AcceptNewsletter] AS [AcceptNewsletter], 
[Limit1].[DateCreated] AS [DateCreated], 
[Limit1].[LastUpdate] AS [LastUpdate], 
[Limit1].[IdAddress] AS [IdAddress], 
[Limit1].[IdDocument] AS [IdDocument], 
[Limit1].[IdDiscountApproval] AS [IdDiscountApproval], 
[Limit1].[IsEmailValid] AS [IsEmailValid], 
[Limit1].[TimeLimitConfirm] AS [TimeLimitConfirm], 
[Limit1].[FacebookId] AS [FacebookId], 
[Limit1].[TwitterId] AS [TwitterId], 
[Limit1].[OnFacebookCreated] AS [OnFacebookCreated], 
[Limit1].[OnTwitterCreated] AS [OnTwitterCreated], 
[Limit1].[IdDocument1] AS [IdDocument1], 
[Limit1].[IdDocumentType] AS [IdDocumentType], 
[Limit1].[Document] AS [Document]
FROM ( SELECT TOP (1) 
    [Extent1].[IdUser] AS [IdUser], 
    [Extent1].[MobileCode] AS [MobileCode], 
    [Extent1].[MobileSession] AS [MobileSession], 
    [Extent1].[Name] AS [Name], 
    [Extent1].[Email] AS [Email], 
    [Extent1].[IdCountry] AS [IdCountry], 
    [Extent1].[Password] AS [Password], 
    [Extent1].[PasswordSalt] AS [PasswordSalt], 
    [Extent1].[Sex] AS [Sex], 
    [Extent1].[Birthday] AS [Birthday], 
    [Extent1].[TelephoneNumber] AS [TelephoneNumber], 
    [Extent1].[CellphoneNumber] AS [CellphoneNumber], 
    [Extent1].[Cep] AS [Cep], 
    [Extent1].[AcceptNewsletter] AS [AcceptNewsletter], 
    [Extent1].[DateCreated] AS [DateCreated], 
    [Extent1].[LastUpdate] AS [LastUpdate], 
    [Extent1].[IdAddress] AS [IdAddress], 
    [Extent1].[IdDocument] AS [IdDocument], 
    [Extent1].[IdDiscountApproval] AS [IdDiscountApproval], 
    [Extent1].[IsEmailValid] AS [IsEmailValid], 
    [Extent1].[TimeLimitConfirm] AS [TimeLimitConfirm], 
    [Extent1].[FacebookId] AS [FacebookId], 
    [Extent1].[TwitterId] AS [TwitterId], 
    [Extent1].[OnFacebookCreated] AS [OnFacebookCreated], 
    [Extent1].[OnTwitterCreated] AS [OnTwitterCreated], 
    [Extent2].[IdDocument] AS [IdDocument1], 
    [Extent2].[IdDocumentType] AS [IdDocumentType], 
    [Extent2].[Document] AS [Document]
    FROM  [dbo].[User] AS [Extent1]
    LEFT OUTER JOIN [dbo].[Document] AS [Extent2] ON [Extent1].[IdDocument] = [Extent2].[IdDocument]
    WHERE (([Extent2].[Document] = @p__linq__0) AND ( NOT ([Extent2].[Document] IS NULL OR @p__linq__0 IS NULL))) OR (([Extent2].[Document] IS NULL) AND (@p__linq__0 IS NULL))
)  AS [Limit1]',N'@p__linq__0 nvarchar(4000)',@p__linq__0=N'01420276506'
our command:

_____var query = (from u in DbSet
                     where u.Document.Number.Equals(document)
                     select u).ApplyIncludes("Document");
return query.FirstOrDefault();_____

As you can see, the last one query is doing ( NOT ([Extent2].[Document] IS NULL OR @p__linq__0 IS NULL)))

I'm sharing some images about EF5 and EF6 queries's execution plan where we can prove.

EF5 execution plan image: https://dl.dropboxusercontent.com/u/18848631/EF%205.png

EF6 execution plan image: https://dl.dropboxusercontent.com/u/18848631/EF%206.png

Queries link:
https://dl.dropboxusercontent.com/u/18848631/EF%205.txt
https://dl.dropboxusercontent.com/u/18848631/EF%206.txt

We are not using Migration and our database strategy is Null.

Thank you so much.

New Post: EF6 RC1 returning different queries from EF5, but slower and degrading performance.

$
0
0
Guys, I just saw that:

Configuration.UseDatabaseNullSemantics property did it. I really would like to know why "false" is the default value. I guess you guys should consider change it to true, please.

No way.(

New Post: EF6 RC1 returning different queries from EF5, but slower and degrading performance.

$
0
0
Hello,

Glad to hear you found the UseDatabaseNullSemantics flag. I was about to suggest you tried setting it to true. Thanks for the feedback on the default value. We decided to make it false after many discussions and performance tests because we encountered that a great number of customers found the other option very confusing, frustrating and plain incorrect. In many cases ignoring the differences in the treatment of equality with null values between the database an in-memory processing would lead to subtle application bugs. In our testing we also found that in most cases the performance impact was minimal. We have heard since of a couple of cases in which there is more significant perf impact and we are looking at possible optimizations. We also need to work more on helping customers know about the existence of the flag, which can be used as a workaround.

HTH,
Diego

New Post: EF6 RC1 returning different queries from EF5, but slower and degrading performance.

$
0
0
Hi Diego,


But I guess you guys should keep the "default behavior", once you know that this can cause performance impact and you know that a lot of people are moving to this new version.

Anyway, this express my opinion and if you are building frameworks I guess this is basic principle. Do you think that there are more traps?

So, thank you so much for your fast reply.

New Post: Location of generated models and mapping in solution

$
0
0
Hi there

Is it possible to change the location where the models and mappings are generated? If so, can I set a location in the T4 templates?

Thanks in advance!

Loetn

New Post: Poor performance for nullable columns

$
0
0
Hi all,

This thread on stackoverflow highlights an issue I have with the SQL generation of EF6.

http://stackoverflow.com/questions/17323547/should-the-order-of-linq-query-clauses-affect-entity-framework-performance/17873031#17873031

A simple change that will have the same effect is

Common SQL constructions for handling nullable equality comparisons do have specific SQL Server query optimizer support. One (of the many) compatible SQL query forms is (as suggested from stack overflow):

(x = y) OR (x IS NULL AND y IS NULL)
The EF-generated SQL instead follows this pattern:

((x = y) AND NOT (x IS NULL OR y IS NULL)) OR (x IS NULL AND y IS NULL)


I would code this fix/change myself but I don't know where to start looking in the codebase. :-)

New Post: Poor performance for nullable columns

$
0
0
Hello ocdi,

Thanks for the heads up on that StackOverflow thread. I have responded there with some information that might be interesting to you, but I am going to summarize it here in case it is useful:

In EF6 we have introduced the extra null checking terms to compensate for differences between the semantics of null comparisons in the database (three-valued logic) and standard in-memory null comparisons. The goal of this is to satisfy the following very popular request:

Incorrect handling of null variables in 'where' clause

The new behavior is controlled by a public flag, so you can turn it off and get the previous behavior very easily:
context.Configuration.UseDatabaseNullSemantics = true;
In the following expression:
((x = y) AND NOT (x IS NULL OR y IS NULL)) OR (x IS NULL AND y IS NULL)
That extra 'AND NOT (x IS NULL OR y IS NULL)' part is added with the goal of avoiding returning incorrect results in the particular case in which either x or y are NULL but both aren't null at the same time and the whole comparison expression is negated in the query.

We have a work item tracking the possibility of making our query optimizer smarter to remove this expression when it isn't strictly unnecessary, e.g. when we know that the comparison expression is not negated as part of the query.

#1598 [Performance] Reduce the expression tree for complex queries in case of C# null comparison semantics

New Post: How can I join tables with different data types using Entity Framework

$
0
0
With the situation of using Entity Framework,I want to join tables with two field in same value,but the fields are identified with different data types. For example,there is a field which the data type is 'Guid',but in another table the associated field is 'string' type. I am confused to achieve the goal. Can somebody give me some ideas.Here are my codes:

var dbEmp = zbdlcontext.Emp_Manager;
            var dbCompany = zbdlcontext.Corp_CompanyInfos;
            var dbFlowCode = zbdlcontext.FlowCodes;
            var dbEmpPost = zbdlcontext.Emp_Post;
            var query = from emps in dbEmp
                        join companies in dbCompany on emps.CorpGuid equals companies.CorpUserGuid
                        join flowCode in dbFlowCode on new { EmpGuid = emps.EmpGuid.ToString(), AreaCode = areaCode } equals new { EmpGuid = flowCode.ObjectId, AreaCode = flowCode.AreaCode } into jFlowCodes
                        from flowCodes in jFlowCodes.DefaultIfEmpty()
                        join post in dbEmpPost on emps.EmpGuid equals post.EmpGuid into jPosts
                        from posts in jPosts.DefaultIfEmpty()
                        select new tb_Emp_Manager()
                        {
                            EmpGuid = emps.EmpGuid,
                            AreaCode = emps.AreaCode,
                            FlowCode = flowCodes.FlowCode,
                            corpName = companies.CorpName
                        };
join flowCode in dbFlowCode on new { EmpGuid = emps.EmpGuid.ToString(), AreaCode = areaCode } equals new { EmpGuid = flowCode.ObjectId, AreaCode = flowCode.AreaCode } into jFlowCodes
                        from flowCodes in jFlowCodes.DefaultIfEmpty()
Viewing all 1793 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>