问题描述
我在同一个项目中有两个看起来不同的数据库上下文。 一个继承自不同的基类并具有不同的构造函数。
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 (将#修改为@)