我正在尝试GrapQL.EntityFramework
在 Azure 函数上使用 DB 优先方法进行集成。我已经生成了所需的上下文、用户图、查询以及函数本身。Startup
目前,我在使用依赖注入的函数应用程序的文件中遇到问题。
我在GraphQL.EntityFramework Docs的配置指南中尝试了这两个选项。我还尝试过一些代码片段,例如builder.Services.AddSingleton(typeof(IEfGraphQLService<PersonarDBContext>),instance => { return new DBContext(); });
我的启动文件的当前状态
public override void Configure(IFunctionsHostBuilder builder)
{
string connection = ""
builder.Services.AddTransient<UserQuery>();
builder.Services.AddDbContext<DBContext>(options => options.UseSqlServer(connection));
var optionBuilder = new DbContextOptionsBuilder<DBContext>();
optionBuilder.UseSqlServer(connection);
EfGraphQLConventions.RegisterInContainer<DBContext>(builder.Services, null);
EfGraphQLConventions.RegisterConnectionTypesInContainer(builder.Services);
builder.Services.AddSingleton(typeof(IEfGraphQLService<DBContext>),instance => { return new DBContext(); });
}
此时我只是试图让我的函数应用程序正确启动。我目前正在遇到此错误输出。
用户:Microsoft.Azure.WebJobs.Host:错误索引方法“用户”。Microsoft.Azure.WebJobs.Host:无法将参数“服务”绑定到类型 IEfGraphQLService`1。确保绑定支持参数类型。如果您正在使用绑定扩展(例如 Azure 存储、ServiceBus、计时器等),请确保您已在启动代码中调用了扩展的注册方法(例如 builder.AddAzureStorage()、builder.AddServiceBus( )、builder.AddTimers() 等)。