asp.net mvc - DbContext constructor with connString causes problems with EF Migrations and EF Powertools -
i pass connection string constructor of dbcontext. way has been answered here: pass connection string code-first dbcontext
(code if don't click)
public mycontext(string connstring) : base(connstring) { } however, when attempt enable migrations receive error: "the target context '...' not constructible. add default constructor or provide implementation of idbcontextfactory."
also, when attempt use ef powertools generate entity data model receive error: "a constructible type deriving dbcontext not found in selected file."
is common problem? have fix, feels hack. 1 else have deal before?
add empty constructor, e.g...
public mycontext() { } thing once define parametrized ctor default 1 gets hidden
e.g. see why default parameterless constructor go away when create 1 parameters
that's 1 way of 'hiding' default construction outside users.
usually don't expose 'other' ctor outside - 'yours', hardcode inside need. or alternatively , better - use 'app.config' specify connection string. details (and problems it) see...
migration not alter table
migration not working wish... asp.net entityframework
Comments
Post a Comment