-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Can´t generate migrations using .NET Core Tools MSBuild from the CLI #7341
Comments
@bricelam in triage we said this was a duplicate of an other issue, but I am not sure of which one. Can you help? |
@armartinez If you're interesting it trying out the latest tools where a lot of issues like this have been fixed, see #7358 |
It seems to work with netstandard libraries in 2017, except
|
@CumpsD Using |
I had to use --startup-project and point to a console app |
Oh that's right. SQL Server is packaged in a way that won't work with just .NET Standard. With SQLite, any command that doesn't open a database connection should work. |
@bricelam - Hi Brice, can you give us an example please? Iv'e just hit this in a dotnet core web app using npgsql, and I'm not exactly clear on how to proceed. Actual Exception is:
My EF stuff is in a seperate .NETStandard class library, in a folder called "gis.database", while the actual web app running standalone is in '../gis.web/' How can I make ef migrations run in this case, based on your comments above? |
cd gis.database/
dotnet ef migrations add MyMigration --startup-project ../gis.web/ |
Thanks for that Brice. |
There's an easier way. Make your DB project executable (with dummy Main method).
And implement IDesignTimeDbContextFactory class. |
@tomchovanec thanks for that, but I'm an old Unix hack, so click is perfect for me :-) |
Click=CLI stupid autocorrect :-) |
Just wondering if the requirement for an executable project will ever be removed it is so annoying. |
@Aday12345 It comes down to priorities. It's a lot of work, and there are probably more valuable things things we could do instead. |
Trying the method above I just get
... The reason I wanted to avoid IDesignTimeFactory is because the information in there is already in the DI pipeline.... EDIT: "just not in the format that it wants." Exactly. https://stackoverflow.com/a/54222348/2496266 You must call it CreateWebHostBuilder ...no other custom name will work. |
I can´t generate a new migration from a class library project even when setting a valid ASP.NET Core Web API application as a startup project.
Steps to reproduce
Further technical details
EF Core version: 1.1.0
EF Core Tools version: 1.0.0-msbuild2-final
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Mac OS 10.12.2
IDE: Visual Studio Code
The text was updated successfully, but these errors were encountered: