-
I was following this video from Lombiq, and although I did exactly the same, still I am not abled to see the Part in Content Parts. I should mention that I did enable the module, restarted the application, but still the part that I created does not appear in Content Parts. public class Migrations : DataMigration
{
private readonly IContentDefinitionManager _contentDefinitionManager;
public Migrations(IContentDefinitionManager contentDefinitionManager)
{
_contentDefinitionManager = contentDefinitionManager;
}
public async Task<int> CreateAsync()
{
// Form
await _contentDefinitionManager.AlterPartDefinitionAsync("PersonPart", part => part
.Attachable()
.WithField("Biography", field => field
.OfType("TextField")
.WithDisplayName("Biography")
.WithSettings(new TextFieldSettings
{
Hint = "Persons biography"
})
.WithEditor("TextArea")
)
.WithDescription("Person Part"));
await _contentDefinitionManager.AlterTypeDefinitionAsync("Person Page", type => type
.Creatable()
.Listable()
.WithPart("PersonPart")
.Stereotype("Widget"));
return 1;
}
} And Startup.cs public class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.Configure<TemplateOptions>(o =>
{
o.MemberAccessStrategy.Register<PersonPart>();
});
services.AddContentPart<PersonPart>()
.UseDisplayDriver<PersonPartDisplayDriver>();
services.AddScoped<IDataMigration, Migrations>();
}
public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
{
routes.MapAreaControllerRoute(
name: "Home",
areaName: "OrchardCore.Demo",
pattern: "Home/Index",
defaults: new { controller = "Home", action = "Index" }
);
}
} Is it something that I am missing, do we have to run migrations to update the db with the new models, or what is might be causing this issue? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It needed |
Beta Was this translation helpful? Give feedback.
-
Sure, in case you already applied the migration you can start a new one |
Beta Was this translation helpful? Give feedback.
It needed
services.AddDataMigration<Migrations>();
to apply migrations.