Skip to content
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

EF Code First Migrations failure in VS 2022 #2092

Closed
alexmaie opened this issue Feb 6, 2023 · 3 comments
Closed

EF Code First Migrations failure in VS 2022 #2092

alexmaie opened this issue Feb 6, 2023 · 3 comments

Comments

@alexmaie
Copy link

alexmaie commented Feb 6, 2023

Hi EF6 Team,

I have to reopen this ticket: #1870
I know and understand that EF6 is not being actively maintained, but since you created a netstandard 2.1 compatible version of EF6, then you also need to make sure that we can still create migrations. Right now our only option is to use VS 2019 and and to create a slim solution which only contains some older code related to EF since we can't run net6 code in VS 2019

@kemsky
Copy link

kemsky commented Mar 7, 2023

@alexmaie, ha-ha, I bet they regret they made netstandard 2.1.

You can create migrations using small hacks.

  <PropertyGroup>
    <EF6>false</EF6>
    <EF6Command>[command required]</EF6Command>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="EntityFramework" Version="6.4.4" GeneratePathProperty="true" />
  </ItemGroup>
  <Target Name="Migration" AfterTargets="Publish" Condition="$(EF6) AND '$(TargetFramework)' != 'net48'">
    <Message Text="Executing EF6 command:" Importance="high" />
    <!-- I'm using Microsoft.Data.SqlClient, it may not be needed in your case  -->
    <Copy SourceFiles="$(MSBuildProjectDirectory)\$(PublishDir)runtimes\win\lib\netcoreapp3.1\Microsoft.Data.SqlClient.dll" DestinationFiles="$(MSBuildProjectDirectory)\$(PublishDir)Microsoft.Data.SqlClient.dll" Condition="'$(OS)' == 'Windows_NT'" />
    <Copy SourceFiles="$(MSBuildProjectDirectory)\$(PublishDir)runtimes\win-x64\native\Microsoft.Data.SqlClient.SNI.dll" DestinationFiles="$(MSBuildProjectDirectory)\$(PublishDir)Microsoft.Data.SqlClient.SNI.dll" Condition="'$(OS)' == 'Windows_NT'" />
    <Copy SourceFiles="$(MSBuildProjectDirectory)\$(PublishDir)runtimes\win-x64\native\sni.dll" DestinationFiles="$(MSBuildProjectDirectory)\$(PublishDir)sni.dll" Condition="'$(OS)' == 'Windows_NT'" />
    
    <Copy SourceFiles="$(MSBuildProjectDirectory)\$(PublishDir)runtimes\unix\lib\net6.0\Microsoft.Data.SqlClient.dll" DestinationFiles="$(MSBuildProjectDirectory)\$(PublishDir)Microsoft.Data.SqlClient.dll" Condition="'$(OS)' != 'Windows_NT'" />

    <Copy SourceFiles="$(PkgEntityFramework)\tools\netcoreapp3.0\any\ef6.dll" DestinationFiles="$(MSBuildProjectDirectory)\$(PublishDir)ef6.dll" />
    <Copy SourceFiles="$(MSBuildProjectDirectory)\ef6.runtimeconfig.json" DestinationFiles=" $(MSBuildProjectDirectory)\$(PublishDir)ef6.runtimeconfig.json" />

    <!-- todo: change DAL.Model.dll to your dll -->
    <Message Text="dotnet exec --runtimeconfig $(MSBuildProjectDirectory)\$(PublishDir)ef6.runtimeconfig.json $(MSBuildProjectDirectory)\$(PublishDir)ef6.dll $(EF6Command) --assembly $(MSBuildProjectDirectory)\$(PublishDir)DAL.Model.dll --project-dir $(MSBuildProjectDirectory)" Importance="high" />
    <Exec Command="dotnet exec --runtimeconfig $(MSBuildProjectDirectory)\$(PublishDir)ef6.runtimeconfig.json $(MSBuildProjectDirectory)\$(PublishDir)ef6.dll $(EF6Command) --assembly $(MSBuildProjectDirectory)\$(PublishDir)DAL.Model.dll --project-dir $(MSBuildProjectDirectory)" WorkingDirectory="$(MSBuildProjectDirectory)\$(PublishDir)" ConsoleToMSBuild="true" />
  </Target>

ef6.runtimeconfig.json:

{
  "runtimeOptions": {
    "tfm": "netcoreapp3.0",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "7.0.0"
    }
  }
}
dotnet publish -c Debug --framework NET7.0 /p:ef6=true /p:EF6Command="migrations add MigrationName"

@gallop1
Copy link

gallop1 commented Apr 25, 2023

Is there a Chinese language pack provided with corresponding method annotations?(有没有对应方法注释的中文语言包提供了?)@kemsky ,I dowload it with EntityFramework.zh-Hans 6.2.0 ,I find I can use in Chinese with Method annotations.
(我用EntityFramework.zh-Hans 6.2.0下载了它,我发现我可以在中文中使用Method注释。) @kemsky ajcvickers

@ajcvickers
Copy link
Member

This issue has been closed because EF6 is no longer being actively developed. We are instead focusing on stability of the codebase, which means we will only make changes to address security issues. See the repo README for more information.

@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants