Closed Rick-Anderson closed 8 years ago
cc @pgrudzien12 @DamienPontifex
@Rick-Anderson Could you please more specifics?
@danroth27 I believe that @Rick-Anderson is speaking of the comments made on the docs concerning integration of EF6 with Asp.Net Core, notably:
Now that I have the connection string configured, I'm stuck on the next step - enabling migrations and setting up the database. I tried the following 2 commands in Package Manager Console:
1) Scaffold-DbContext "myConnectionString" Microsoft.EntityFrameworkCore.SqlServer
This failed with "The term 'Scaffold-DbContext' is not recognized as the name of a cmdlet, function, script file, or operable program..."
2) Enable-Migrations
This failed with the message "Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStuido.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version-14.1.0.0, culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable" At C:\Users\myUserProfile.nuget\packages\EntityFramework\6.1.3\tools\EntityFramework.psml:718 char:5
- $domain.SetData('project', $project)
Is Package Manager Console still the tool to use to create and modify databases in .NET Core with EF6? If so, any idea what I'm doing wrong?
Many thanks!
It seems that the docs maybe lacking with regards to actually get a working example of EF6 with asp.net core. Any clarification, limitations and/or caveats that can be documented would be great addition.
@rowanmiller @divega
Enable-Migrations
and other migrations commands fail with project.json based projects because they only support a subset of the functionality that the implementation of commands in EF6 require.
Scaffold-DbContext
on the other hand is Entity Framework Core specific. It won't work for EF6 in any kind of project. If you need to do reverse engineering of a database into an EF6 model my recommendation would be to do it using the EF6 Tools as documented in https://msdn.microsoft.com/en-us/jj200620.
For both issues my general recommendation would be to move the EF6-related code, i.e. the DbContext
and model into a regular .NET 4.x, .csproj based, class library, as neither the EF6 Tools nor the EF6 migrations commands were designed to work with project.json/xproj based projects.
There might be more advanced workarounds and I expect the migration commands to work again long term when everything becomes MSBuild based, but in the meanwhile could we do this exercise of having the model moved into a .csproj class library and update the documentation topic accordingly?
Changed the doc to show Diego's approach in PR #1864
@divega thanks for the response.
@tdykstra, checking out your updates in #1864... noticed that the link to the 'Visual Studio Sample Solution' is broken.
@j0nscalet the link will work after the changes are merged to master, for now you can see the code in the ef6 branch
Oh yea, DUH! Thanks @tdykstra!
cc @tdykstra