dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.57k stars 390 forks source link

Should EF-based components reference Microsoft.EntityFrameworkCore.Design? #740

Closed mitchdenny closed 6 months ago

mitchdenny commented 9 months ago

If you manually wire up a DbContext and use an EF-based Aspire component and then use the EF tools to create the initial migration, EF will fail because the project doesn't have a reference to Microsoft.EntityFrameworkCore.Design. Should we consider pre-adding this as a transitive dependency on components that are targetting entity framework to streamline this workflow?

DamianEdwards commented 9 months ago

Related #398

AndriySvyryd commented 6 months ago

Note that Microsoft.EntityFrameworkCore.Design is generally not meant to be used at runtime. It's important to avoid Aspire or the app assembly from referencing it as it could lead to trimming and NativeAOT warnings. The EF tools just need it to be located in the output directory, i.e. it's a development dependency.

mitchdenny commented 6 months ago

Assigning to @JamesNK to look at as part of the all up database work.

JamesNK commented 6 months ago

EF Core splits it out into a separate package for good reasons. I don't see why components would be different.

If you need Microsoft.EntityFrameworkCore.Design then you should add it to the project.

JamesNK commented 6 months ago

I'm going to close this. If people think more research or discussion is required then feel free to reopen.