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

Cannot find DbContext if Context doesn't inherit from DbContext directly. #133

Closed
kourosko opened this issue Aug 4, 2016 · 2 comments
Closed
Labels
Milestone

Comments

@kourosko
Copy link
Contributor

kourosko commented Aug 4, 2016

Sorry for my English.
First of all Great, really great job. I strongly believe that the way you do things is the proper way.
I haven't fully tested but I'm implementing it in a new project.
I'll explain the problem.
I have a class BioContext that inherits from BaseContext.
BaseContext inherits from dbContext.
When i go to add new web api controller i don't get BioContext.

I've read you code and found the problem in TrackableEntities.ItemWizard project in class ModelReflectionHelper.cs :

`private static bool InheritsFrom(this Type type, Type comparedType)
{
// Test for null
if (type == null || comparedType == null) return false;

        // Test for interfaces
        if (comparedType.IsInterface)
        {
            return type.GetInterfaces().Any(t => t.FullName == comparedType.FullName);
        }

        // Test for base class
        return type.BaseType != null &&
            type.BaseType.FullName == comparedType.FullName;
    }` 

to=>
private static bool InheritsFrom(this Type type, Type comparedType)
`{
// Test for null
if (type == null || comparedType == null) return false;

        // Test for interfaces
        if (comparedType.IsInterface)
        {
            return type.GetInterfaces().Any(t => t.FullName == comparedType.FullName);
        }

        // Test for base class
        return (type == comparedType||type.IsSubclassOf(comparedType));
    }`  
@tonysneed
Copy link
Collaborator

tonysneed commented Aug 5, 2016 via email

@kourosko
Copy link
Contributor Author

kourosko commented Aug 5, 2016

Problem fixed.

@kourosko kourosko closed this as completed Aug 5, 2016
@tonysneed tonysneed added the bug label Aug 30, 2016
@tonysneed tonysneed added this to the v 2.5.5 milestone Aug 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants