dotnet / dotnet/EntityFramework.Docs

Sample "TwoProjectMigrations" can't load assembly for migration

Open
#4,840 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

I was refactoring my application to support multiple DB providers in accordance with the "TwoProjectMigrations" sample, hitting a roadblock on actually using the migrations for migrating. Turns out I get the same error with the sample:

I hijacked the Worker.Execute() method to run a migration as follows:

```
using var scope = _services.CreateScope();
var services = scope.ServiceProvider;
var context = services.GetService();
context.Database.Migrate();
```

Resulting in this error:

`System.IO.FileNotFoundException: Could not load file or assembly 'SqlServerMigrations, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.`

Is this not the right approach?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.