How can I use CodeFirstStoreFunctions in LinqPad 5?
I have a DbContext
in a .NET Framework 4.8 project that uses CodeFirstStoreFunctions
( https://www.nuget.org/packages/EntityFramework.CodeFirstStoreFunctions/ ).
My DbContext has members like this:
[System.Data.Entity.DbFunction("MyDbContext", "SearchFoobar")] [CodeFirstStoreFunctions.DbFunctionDetails(DatabaseSchema = "dbo")] public IQueryable<SearchFoobarResult> SearchFoobar(string terms) { var termsParam = new System.Data.Entity.Core.Objects.ObjectParameter("terms", typeof(string)) { Value = (object)terms }; return this.ObjectContext.CreateQuery<SearchFoobarResult>("[MyDbContext].[SearchFoobarResult](@terms)", termsParam); }
This works fine when used from a "normal" .NET console or ASP.NET project.
However when I try to use it when the DbContext is loaded directly into LinqPad 5 I get this exception:
'MyDbContext.SearchFoobar' cannot be resolved into a valid type or function. Near member access expression, line 1, column 15.
I've verified that my OnModelCreating
is called when in LinqPad (that's the method that adds modelBuilder.Conventions.Add(new CodeFirstStoreFunctions.FunctionsConvention<KbDbContext>("dbo"));
) and my Linqpad file has a package-reference to EntityFramework.CodeFirstStoreFunctions
as well.