Using EF from asp.net core and .net framework app

.net-standard asp.net-core c# entity-framework entity-framework-core

Question

is it possible to have a common code base for model / context / migrations to use the same SQL DB from asp.net core app (3.1) and .net framework app (4.6.1)? My attempts failed. Is there no other solution than creating two projects, one with EF core in .net core 3.1 assembly and one with EF6 with target 4.6.1.

I tried to create a .net standard 2.0 project (with only EF core) that I can reference from both apps, but that seems not to possible? Failed to use the migration tools, because .net standard 2.0 only an "interface"?

dotnet ef migrations add InitialCreate

> Startup project 'TestStandard.csproj' targets framework
> '.NETStandard'. There is no runtime associated with this framework,
> and projects targeting it cannot be executed directly. To use the
> Entity Framework Core .NET Command-line Tools with this project, add
> an executable project targeting .NET Core or .NET Framework that
> references this project
1
0
2/6/2020 9:43:34 AM

Popular Answer

I guess you won't be able to use EF Core (even through NetStandard) and Net 4.6.1 because of compatibility. You could upgrade Net 4.6.1 at least to 4.7.2 and use EF6 or EF Core.

re: Use the migration tool and net standard 2.0 No, you can not. The solution is to create a NetCore project and use it for running migrations (until you migrate all you projects to net core)

0
2/6/2020 7:22:27 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow