efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Can't make a migration for a generic dbrepository

Open gl3nni3 opened this issue 7 years ago • 2 comments

If you believe you have an issue that affects the security of the platform please do NOT create an issue and instead email your issue details to [email protected]. Your report may be eligible for our bug bounty but ONLY if it is reported through email.

Describe what is not working as expected.

If you are seeing an exception, include the full exceptions details (message and stack trace).

I'm trying to create a migration for a class named GenericRepository but the add migration can't find the context.

Found DbContext 'GenericRepository<Building>'.
Found DbContext 'UserBuildingStorage'.
Finding DbContext classes in the project...
Found DbContext 'BuildingStorage'.
Microsoft.EntityFrameworkCore.Design.OperationException: No DbContext named 'GenericRepository<Building>' was found.
   at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.FindContextType(String name)
   at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_1.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
No DbContext named 'GenericRepository<Building>' was found.

Steps to reproduce

Include a complete code listing (or project/solution) that we can run to reproduce the issue.

Create a generic repository for a dbcontext and try to make a context. Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.

Console.WriteLine("Hello World!");

Further technical details

EF Core version: netcoreapp2.2 Database Provider: npgsql.EntityFrameWorkCore.PostGreSQL/2.2.4 Operating system: Pop!_os 19.04 IDE: Rider

gl3nni3 avatar Jul 04 '19 13:07 gl3nni3

Please post a small, runnable project/solution or complete code listing that demonstrates that behavior you are seeing.

ajcvickers avatar Jul 05 '19 15:07 ajcvickers

EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it.

BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.

ajcvickers avatar Jul 12 '19 15:07 ajcvickers