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

PackageReference breaks Entity Framework 6 #1197

Closed
vsfeedback opened this issue Aug 27, 2019 · 12 comments
Closed

PackageReference breaks Entity Framework 6 #1197

vsfeedback opened this issue Aug 27, 2019 · 12 comments

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


What steps will reproduce the problem?

  1. Create a new console project ConsoleApp1, specifying PackageReference architecture instead of Packages.config
  2. Add the EntityFramework.SqlServerCompact package (note that its dependencies include EntityFramework)
  3. Add a class to the project that inherits from DbContext
  4. Run Enable-Migrations from the Package Manager Console
  5. Note the resulting error: "The EntityFramework package is not installed on project 'ConsoleApp1'"

What is the expected output? What do you see instead?
Expected:
Creation of a Migrations folder containing a Configuration class (i.e. Code First Migrations are enabled)

Actual:
The above error message

Please provide any additional information below.
Workaround:
We can install the EntityFramework package prior to installing the EntityFramework.SqlServerCompact package in order to mitigate this problem. However, this extra step shouldn't be necessary. The Enable-Migrations CmdLet should be able to walk package dependencies and discover that the requisite packages are installed.


Original Comments

(no comments)


Original Solutions

(no solutions)

@ajcvickers
Copy link
Member

Which release of EF6 are you using?

@InteXX
Copy link

InteXX commented Aug 27, 2019

v6.2, the latest stable version.

I also found another related problem: under PackageReference, Add-Migration always uses System.Data.SqlClient—even if there's no reference to the assembly. I wasn't able to get it to use System.Data.SqlCeClient, resulting in a connection-string-related crash while attempting to generate the migration.

The only way I could get it working was to return to packages.config. Here's the code I'm using to create the connection string:

Public Shared ReadOnly Property DbConnectionString As String
  Get
    With New SqlCeConnectionStringBuilder
      .MaxDatabaseSize = 4091
      .MaxBufferSize = 1024
      .CaseSensitive = False
      .FlushInterval = 1
      .DataSource = "Queue.sdf"
      .FileMode = "read write"
      .Encrypt = False
      .Enlist = True

      Return .ConnectionString
    End With
  End Get
End Property

The crash is due to SqlClient not supporting these keywords (CaseSensitive, FileMode, etc.).

@ajcvickers
Copy link
Member

@InteXX Generally speaking, EF 6.2 doesn't work with SDK-style projects and package references. This is fixed for 6.3--see #231. However, we are not updating the SQL Compact package for 6.3 because SQL Compact is end-of-life.

@InteXX
Copy link

InteXX commented Aug 29, 2019

@ajcvickers

Very good, thank you.

Note: SqlCe doesn't hit EOL until July 2021. Nevertheless, is the v6.2 package expected to work with EF6.3?

That said, it appears that v6.3 is being worked on: https://www.nuget.org/packages/EntityFramework.SqlServerCompact/6.3.0-preview8-19405-04

@ajcvickers
Copy link
Member

@InteXX The package still exists, and it may also happen to work with package references due to picking up changes made for the other packages, but it isn't a goal to bring this package to .NET Core or the new project system. What works works, what doesn't work, doesn't work.

@ErikEJ
Copy link
Contributor

ErikEJ commented Oct 9, 2021

@InteXX I have created an unofficial port of the SQL Compact provider to .NET Core: https://github.com/ErikEJ/EntityFramework6PowerTools/tree/community/src/ErikEJ.EntityFramework.SqlServerCompact

@InteXX
Copy link

InteXX commented Oct 10, 2021

That looks great, thanks. Is there a corresponding NuGet package?

Eventually I'd like to contribute a VB.NET SQL generator for it, but that's only a long-term goal at this point.

@ErikEJ
Copy link
Contributor

ErikEJ commented Oct 10, 2021

There is, just look at the readme at the link

@InteXX
Copy link

InteXX commented Oct 10, 2021

I did, but I didn't find a package name. Maybe I'm looking right past it.

I did find this in the .csproj, though, inside the <PackageID/> tag: ErikEJ.EntityFramework.SqlServerCompact

@ErikEJ
Copy link
Contributor

ErikEJ commented Oct 10, 2021

That's the package name. Have you added the additional Nuget source?

@InteXX
Copy link

InteXX commented Oct 10, 2021

No project open at this time. Just looking. I'll give it a try tomorrow.

We should probably stop hijacking this thread. My fault.

@ErikEJ
Copy link
Contributor

ErikEJ commented Oct 10, 2021

I have updated the readme to make the package name clearer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants