-
Notifications
You must be signed in to change notification settings - Fork 545
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
Make EF NuGet package / migrations and EF Tools work with new csproj format #231
Comments
Hi, Do you have prevision to new version EF 6.3.2 ? |
I'm also having this issue in EF 6.1.3 in a WebAPI + Xamarin PCL. I get the following exception:
|
This is dotnet/project-system#934. |
OMG so no migrations until 6.3? Any roadmap/workaround? |
@weitzhandler Migrations works now, just not with the new csproj infrastructure. Is there something that is stopping you using the traditional project system? |
Just use the existing project system |
@ErikEJ @ajcvickers thanks for your reply, I probably got it wrong. What do you guys refer to when saying 'traditional project system'? This project was created in VS2017, and it's a csproj. |
@ErikEJ @ajcvickers I have the same question as @weitzhandler. When you say traditional/existing project system, do you mean VS2015 (net461), or simply VS2017 with the old project.json project file? |
Correct |
@divega |
@weitzhandler can you please explain exactly what you mean with that? Sorry if it can be inferred from the context above, but I haven’t read the whole thread. |
@divega |
@weitzhandler thanks for clarifying. I don't think we can answer that yet. Our main strategy for ASP.NET Core and .NET Core in general is to make EF Core a very compelling solution, but that includes closing some of the feature gaps with EF6, as you point out, and that is going to take a few releases. On the flips side, working with EF6 in an ASP.NET Core application is possible but requires workarounds. E.g. in this case, keep the model in a separate .NET Framework library with a traditional project file, and unload any projects from the solution that use the new project system while working with migrations. We are reluctant to commit to making EF6 migrations fully work with the new project system because we believe that would involve a significant investment which would hinder our progress on our main strategy, but perhaps there are less expensive things we can do to reduce the friction of the workarounds, e.g. make it so that you still need to put the EF6 model in a separate project but at least you don't need to unload other projects. Does that make sense? |
This is one of the main reasons I won't touch the new project system (or even .net core really). The lack of on parity tooling means it adds more headaches than it solves. Not to mention the new project system shines when doing things like EF migrations because of all the files that are added. So realistically the projects that benefit from it the most (EF and websites) don't support it and negate moving anything to it. |
I have updated the original issue to explain some of the options. |
In my current scenario moving the model to a separate assembly is not an option. The models have partial classes that are ASP.NET specific. BTW @divega this repo helped me get my project to work with migrations. |
This is a back-port of the architecture used by EF Core. It enables F#, x64, .NET Core, and cross-targeting projects. PowerShell 3.0 is now required its for JSON support. This adds ef6.exe which will eventually replace migrate.exe Part of dotnet#231
This is a back-port of the architecture used by EF Core. It enables F#, x64, .NET Core, and cross-targeting projects. PowerShell 3.0 is now required its for JSON support. This adds ef6.exe which will eventually replace migrate.exe Part of dotnet#231
Work to make the PMC commands (Add-Migration, Update-Database, etc) compatible with .NET Core 3.0 projects is well underway. Unfortunately, nothing made it into 3.6.0-preview7, but it's on track for Preview 8 (August). On a related note, do we also need a |
@bricelam a strong YES. How unclear is it that migrations are pivotal to running 6.3.0? You can't responsibly run databases without migrations. It is CORE to them, literally the same as asking can/should you develop without a code repository. How is that even a question? |
@marchy I think you misread my last comment. Migrations commands WILL work in 6.3.0. |
@bricelam if that's the case then my apologies. I understood it as contemplating whether support for EF 6 migrations should be warranted (VS just EF Core), rather than maintaining support for @mrahhal's Migrator.EF6's project which has been filling the stop-gap prior to the upcoming official support. To clarify, will the EF6 migration commands be user-invocable (ie: as simple as We don't use Visual Studio at all (use Rider instead) and have always used the terminal/CLI for migration commands even when VS was part of our toolset. Thanks for your clarifications around this. |
Yes, this issue is about making the existing EF6 Migrations commands (Update-Database, Add-Migration, etc.) work with .NET Core (aka SDK-style) projects. My latest PR (#1058) completes this work. |
I have an exception while adding migration. Full text of the error:
Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio
Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio
System.NullReferenceException: Object reference not set to an instance of an object. Please, ask for more information if needed. |
@RomanHubyak This issue was not fixed for preview 6. The first preview that contains this fix will be preview 8. Or you should be able to try it now using the nightly builds. |
@bricelam the migrations commands still don't work in EF 6.3 / .NET Core 3.0 Preview 9 + Visual Studio 2019 16.3.0 Preview 3. Running from the Package Manager Console, getting the following error when targeting a newly-updated
We missing something? |
@marchy .NET Standard projects are not supported--only .NET Core projects. Can you submit a new issue requesting support for these? The reason is that there is no runtime associated with .NET Standard--it's just a spec/interface--so we can't execute the code to build your model. We've mitigated this on EF Core by executing code through the startup project. This lets you put your DbContext in a .NET Standard class library so long as you have a .NET Core app referencing it that you can use to execute code. We didn't want to break existing workflows by dramatically changing the way the commands execute your code to build the model. However, I'm sure we can find a non-breaking way to enable this if there is sufficient demand. Out of curiosity, in what other frameworks besides .NET Core 3.0 are you using your .NET Standard 2.1 library? |
I'm struggling with this and I wonder if anyone could help. I have a solution, with a WebApi and a class library (there are many more projects but they are irrelevant to this) which contains the EF code (Context, Migrations Entities and so on). All projects are running on .NET Framework 4.7.2. No .NET Core involved here. I'm currently migrating all projects to the new SDK I assumed that with the latest bits ( I simply run this, as I normally do
And the error it gives me is: Tried running with the old tools, also doesn't work. Do I need to add anything special in my |
@joaopgrassi Does |
Hi, @bricelam. I started creating a repro and there it worked. So, I went to my project and did the same steps and it worked. Not sure what was up. But I faced a new problem along the way. Will submit a new issue. Thanks! |
@bricelam still doesn't work even if running it in context of referencing projects. Running from both a ASP.NET Core 3.0 web app and a .NET Core 3.0 console app, error is:
All 3 projects (library, console app, web app) have just been upgraded to RC1 and issuing the migration commands from the new Visual Studio 16.3.0 Preview 4.0. |
I ran into the very same issue when using a .Net Framework app with the new SDK project format. To fix, it was enough to upgrade Entity Framework to version 6.4 (I guess anythign 6.3+ will work). |
the absence of BindingRedirects can cause problems. Such as:
To resolve, ensure you are on EF 6.4, then try You can workaround it by manually calling EF6.exe and passing the .config of the built assembly.
|
Workaound:
Currently the following workaround works (tested on an ASP.NET Core 2.0 app):
Options:
We could consider
Original issue:
See #230 and #189 and NuGet/Home#4876
See also New csproj format and GenerateSeparateFiles=true causes VS2017 to freeze sjh37/EntityFramework-Reverse-POCO-Code-First-Generator#266 which blocks EF Tools tt codegen with the new csproj files.
The text was updated successfully, but these errors were encountered: