不同数据上下文的把手模板

问题描述

我在同一个项目中有两个看起来不同的数据库上下文。 一个继承自不同的基类并具有不同的构造函数

public partial class DbFirstGraphQLDataContext : DbContext
    {
        public DbFirstGraphQLDataContext(DbContextOptions options) : base(options)
        {
        }

public partial class DbFirstOtherDataContext : DbContextCustomBase
    {
        public DbFirstGraphQLDataContext(DbContextOptions options,IServiceCollection serviceCollection) : base(options,serviceCollection)
        {
        }

我可以先使用典型命令搭建其中一个dotnet ef dbcontext scaffold -c DbFirstGraphQLDataContext ...

我有基本的脚手架设计时间服务:

    public class ScaffoldingDesignTimeServices : IDesignTimeServices
    {
        public void ConfigureDesignTimeServices(IServiceCollection serviceCollection)
        {
            serviceCollection.AddHandlebaRSScaffolding(opts=> opts.TemplateData);
        }
     }

还有 .hbs 文件,我已经粘贴了其中的一部分。如您所见,.hbs 文件用于 DbFirstGraphQLDataContext

{{> dbimports}}
using DA.someInternalRepo;

namespace {{namespace}}
{
    //This file is autogenerated using EF database first. Do not modify it. Customisations can be made using the .hbs template files
    public partial class {{class}} : DbContextCustomBase
    {

我如何编写模板、C# 代码或脚本参数,以便它根据正在呈现的上下文呈现不同的构造函数或基类

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...