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

"Entity framework was detected" false positive #262

Open
jzabroski opened this issue Sep 17, 2019 · 7 comments
Open

"Entity framework was detected" false positive #262

jzabroski opened this issue Sep 17, 2019 · 7 comments

Comments

@jzabroski
Copy link

jzabroski commented Sep 17, 2019

The following code is extremely annoying for me. I am the co-maintainer of FluentMigrator, a migration framework that uses a project structure that may or may not contain the folder name Migrations.

What are you trying to achieve here? Why can't you just check the Project and packages.config for references to the EntityFramework6 package?

// Code-first
if (project.ProjectFolder.EnumerateDirectories().Any(x =>
string.Equals(x.Name, "Migrations", StringComparison.OrdinalIgnoreCase)))
{
return true;
}

I also think, if you're going to raise an ERR level here, you should explain what you're checking in the error message.

@mungojam
Copy link
Collaborator

Fair point, we should fix this

@redwyre
Copy link

redwyre commented Sep 30, 2019

I have the same issue, could use an override to ignore it. Renaming the folder before converting and back after works though.

@jzabroski
Copy link
Author

Yeah, I rename it to Mygrations, ugh.

@mpawelski
Copy link

If someone plan to work on it then it's worth noting that since EF 6.3 migrating to new .csproj is possible

From https://docs.microsoft.com/en-us/ef/ef6/what-is-new/#ef-630

The migrations commands have been rewritten to execute out of process and work with SDK-style projects.

I was able to successfully migrate to new csproj by:

  1. Comment out the code that checks for "Migration" directory or "edmx" files. (If you don't want change CsprojToVs2017 then renaming "Migrations" to "Mygrations" trick should work too)
  2. Running dotnet .\Project2015To2017.Migrate2017.Tool\bin\Debug\netcoreapp2.1\dotnet-migrate-2017.dll migrate --no-backup C:\projects\MyOldProjectWithOldCsproj
  3. Removing "<Compile Update=" and "<EmbeddedResource Update=" from project with EF migrations. I used this regexes (replace the match with empty string):
<Compile Update="Migrations\\(.|[\s\n])+?<\/Compile>[\n\s]+
<EmbeddedResource Update="Migrations\\(.|[\s\n])+?<\/EmbeddedResource>[\n\s]+
  1. Add <EmbeddedResourceUseDependentUponConvention>true</EmbeddedResourceUseDependentUponConvention> to EF's .csproj or Directory.Build.props file. Without this change I had this error:

"Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "MyOldProjectWithOldCsproj.Migrations.TestMigrationEmpty.resources" was correctly embedded or linked into assembly "MyOldProjectWithOldCsproj" at compile time, or that all the satellite assemblies required are loadable and fully signed."

And it seems that everything works. When I add migration with Add-Migration in VS new migrations files are added without changing .csproj.

Hope this will help some people struggling with migration to new .csproj.

@dahlbyk
Copy link

dahlbyk commented Jan 18, 2021

@hvanbakel if you're still willing to accept changes to this project, I'd be willing to put together a PR to migrate to EmbeddedResourceUseDependentUponConvention for projects with EF 6.3+.

@jzabroski
Copy link
Author

jzabroski commented Jan 18, 2021

@dahlbyk In my experience, with open source, just do it and there is a decent chance it gets merged or forked. Especially now with GitHub Actions its super easy to fork projects like these if the maintainer is falling behind supporting PRs.

@hvanbakel
Copy link
Owner

hvanbakel commented Jan 18, 2021 via email

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

6 participants