Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF 5 support #12

Closed
wants to merge 1 commit into from
Closed

EF 5 support #12

wants to merge 1 commit into from

Conversation

borislitvak
Copy link

EF5/EF6/Linq2Sql support were exported to separate projects. In
addition, there is a new project which holds the DatabaseHelper base
class. Thus, there are 4 new DLLs that need to be added to you LinqPad
scripts directory right now. And why?
I opted going this way as I did not want to go the assembly
aliases/reflection route. Please note we are looking at supporting two
different api versions of the same assembly - EF.
This approach is cleaner, though it introduces additional DLLs to the
user.
P.S.: I did not go the ilmerge route.

EF5/EF6/Linq2Sql support were exported to separate projects. In
addition, there is a new project which holds the DatabaseHelper base
class. Thus, there are 4 new DLLs that need to be added to you LinqPad
scripts directory right now. And why?
I opted going this way as I did not want to go the assembly
aliases/reflection route. Please note we are looking at supporting two
different api versions of the same assembly - EF.
This approach is cleaner, though it introduces additional DLLs to the
user.
P.S.: I did not go the ilmerge route.
@borislitvak
Copy link
Author

There is also https://github.com/Fody/Costura instead of ILMerge, but I did not test this.

@Giorgi
Copy link
Owner

Giorgi commented Apr 12, 2016

Thanks for the PR. I see what you have done but why was the original version failing?

@borislitvak
Copy link
Author

I don't recall the details. You can see in issues #4 and #8 that I was
getting a null reference exception and (ef6) Db Interceptor type not found.
I made a quick reference to ef5, changed some code to extract sql statement
in ef5, and it worked. Then I refactored into the clean solution you see
and committed the code.
So the root of the issue was your code linking with ef6. Btw, maybe it
would have worked had ef6 been in my GAC, but it would still be using ef6,
not ef5 sql generator. You can make this test.

I saw that you've referenced linqpad.exe from the main dll, which looked
strange, but I did not dig into your interaction with the executable.
You have my context, so you can check it yourself, see #8. All of the
above is written from memory.
Boris
On Apr 12, 2016 16:01, "Giorgi" notifications@github.com wrote:

Thanks for the PR. I see what you have done but why was the original
version failing?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#12 (comment)

@Giorgi
Copy link
Owner

Giorgi commented Apr 13, 2016

I don't think the issue was linking with EF6. When you run DumpPlan LINQPad loads EF5 because your dbcontext references it so it won't load EF6. I suspect that the code which was detecting EF version used by the query was wrong but I'm not sure how your code works because neither DBSet nor DbQuery inherits from ObjectQuery so how do you cast the queryable to ObjectQuery ?

@borislitvak
Copy link
Author

Now that I'm not putting my kids to bed (which I was doing during the
previous post) I agree that ObjectQuery usage is erroneous - it does not
distinguish between EF5/6. It distinguishes between ObjectContext and
DbContext (DbQuery), which is still an important but a different issue.

On Wed, Apr 13, 2016 at 10:05 PM, Giorgi notifications@github.com wrote:

I don't think the issue was linking with EF6. When you run DumpPlan
LINQPad loads EF5 because your dbcontext references it so it won't load
EF6. I suspect that the code which was detecting EF version used by the
query was wrong but I'm not sure how your code works because neither DBSet
nor DbQuery inherits from ObjectQuery so how do you cast the queryable to
ObjectQuery ?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#12 (comment)

@Giorgi
Copy link
Owner

Giorgi commented Apr 17, 2016

So this PR is for making the plugin work with ObjectContext instead of DbContext? The sample project that you uploaded was using DbContext so that might explain why the plugin works for that project but not for your other project (if it uses ObjectContext)

@borislitvak
Copy link
Author

Giorgi,

Now that my child was born, I will be more available for replies :)

You are 100% correct, it was about the context. I've added the support for
ObjectContext in my branch which you can see in the PR, but it does not
support DbContext now. So this will need to be changed.

Boris

On Sun, Apr 17, 2016 at 8:35 PM, Giorgi notifications@github.com wrote:

So this PR is for making the plugin work with ObjectContext instead of
DbContext? The sample project that you uploaded was using DbContext so that
might explain why the plugin works for that project but not for your other
project (if it uses ObjectContext)


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#12 (comment)

@borislitvak
Copy link
Author

To be honest, I will not have the time to perform this myself.
In my code you can see ways of retrieving the SQL from the query in EF5, at
least for ObjectContext.

Thanks, Boris

On Sun, Apr 24, 2016 at 10:31 AM, Boris Litvak boris.litvak@gmail.com
wrote:

Giorgi,

Now that my child was born, I will be more available for replies :)

You are 100% correct, it was about the context. I've added the support for
ObjectContext in my branch which you can see in the PR, but it does not
support DbContext now. So this will need to be changed.

Boris

On Sun, Apr 17, 2016 at 8:35 PM, Giorgi notifications@github.com wrote:

So this PR is for making the plugin work with ObjectContext instead of
DbContext? The sample project that you uploaded was using DbContext so that
might explain why the plugin works for that project but not for your other
project (if it uses ObjectContext)


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#12 (comment)

@Giorgi Giorgi closed this Nov 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants