-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entity Framework Migrations issue #15
Comments
The
|
Thanks for the info! I'm assuming that there will be quite a lot of folks using EF with this template and DotNetify for that matter, so maybe this is something worth documenting as a known issue rather than fixing it? I only mention it because it took me quite a while before I started looking in the right place - at first I was looking for the issue within EF itself which is quite a deep rabbit hole :-D. It was only the fact that the error message said something about the view model that led me to believe it must have something to do with DotNetify autodiscovery. So I guess anyone using this in conjunction with EF will need to use either of the two workarounds I put in my first comment and ignore the stack trace on running migrations, or they will need to explicitly register all assemblies that contain view models then? |
This can be properly fixed by deferring the exception-throwing check until the first client-side request is received. I will put this in the next version release. Thanks! |
Fixed in the latest dotNetify release. |
i had a view model derived from BaseVM which is working fine (without adding any additional RegisterAssembly), Now when i added another viewmodel derived from BaseVM, am getting below error - I tried with registering assembly using both by config and RegisterAssembly still same error. app.UseDotNetify(config =>
Please clarify. |
A bit of a strange one, but it seems that when you call:
inside the
Startup.cs
Configure()
method, it runs fine when youdotnet run
it, but as soon as you calldotnet ef migrations add InitialDb
then EF naturally calls thestatic IWebHost BuildWebHost()
method and errors out on the above call with the following stack trace:The only 2 ways to get around this are to
app.UseDotNetify(config =>
part and run your migrations command and then uncomment it each time you want to add or run a migrationIDesignTimeDbContextFactory<TContext>
which basically repeats the same code as you would have inConfigureServices()
for adding SQL Server config - and if you do this, you still see the stack trace in the migration above, but it just keeps going and creates the migration anyway.I'm guessing that
DotNetify
is doing some sort of assembly scanning on startup and finding an assembly called'ef'
which for some reason it expects to have a view model?This issue is not stopping progress, but though some others might like to know the workaround. It would probably be even better if it didn't throw an exception at this stage because of the inner workings of DotNetify, but maybe I just missed something on the config?
The text was updated successfully, but these errors were encountered: