Umbraco 13 documentation use deprecated AddUmbracoEFCoreContext
h
https://docs.umbraco.com/umbraco-cms/tutorials/getting-started-with-entity-framework-core AddUmbracoEFCoreContext is supported Umbraco 12.0.0 I updated the project to Umbraco 12.3.5 because of a recent security patch update now this function keeps giving an error during the add-migration command. So I tried to use AddUmbracoDbContext and started getting the following error message. The DbContext of type 'MyContext' cannot be pooled because it does not have a public constructor accepting a single parameter of type DbContextOptions or has more than one constructor. Could someone direct me on how to use AddUmbracoDbContext in Umbraco 12.3.5 Thanks
i
I don't have a code sample ready, but do you have a context with a constructor like this?
Copy code
c#
public BlogContext(DbContextOptions<BlogContext> options)
        : base(options)
{ }
Where you have a DbContextOptions and inherit from base(options)?
And is it public and not protected/internal
h
My initial point was Umbraco document needs to be updated as it shows a deprecated method. Still Here are my codes: builder.Services.AddUmbracoDbContext(options => options.UseSqlServer(config.GetConnectionString("umbracoDbDSN"))); public MyContext( DbContextOptions options) : base(options) { } The main issue I found Add-migration command required mentioning the context. so if I wrote add-migration Initialize -context MyContext It starts working. EF gets two contexts otherwise.
a
Hi Hasan! As Umbraco is open source, feel free to open a pull request if you've found the answer to correct this! You can find the source on https://github.com/umbraco/UmbracoDocs
23 Views