I am currently trying to integrate Entity Framework (with embedded SQL Server) into Unity project.
My steps are next:
- In external solution I install EF 6 via NuGet, create simple DbContext and code configuration file. Target platform is 4.7.1, because Unity doesn’t support 4.7.2.
- I test it in a console application and everything works fine.
- Then, I copy files from build folder to Plugins.
- Trying to run the same code in Unity.
When I am trying the first time to get DbSet the exception is thrown:
System.PlatformNotSupportedException: LocalDB is not supported on this platform.
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection (System.Data.Common.DbConnection owningObject, System.UInt32 waitForMultipleObjectsTimeout, System.Boolean allowCreate, System.Boolean onlyOneCheckConnection, System.Data.Common.DbConnectionOptions userOptions, System.Data.ProviderBase.DbConnectionInternal& connection) [0x00085] in <8012ff544f1c4cb384c200861f770215>:0
What am I doing wrong?
Is it actually real to integrate EF 6 or EF Core with Unity now?
Well, thanks to everyone.
I ended up with building EF Core + SQLite project, downloading several dependencies into NetFramework project, copying it all to Plugins and got worked.
The problem with LocalDB was that it anyway needs SQL Server installed on computer. And SQLite is portable engine that can work in the same process.
Hey Dalian!
I know this is an old thread, but I’m super desperate to use a dll that references Microsoft.EntityFrameworkCore. Could you tell me how you got your DLLs even working in Unity? I get the following error:
Unable to resolve reference ‘Microsoft.EntityFrameworkCore’. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Unable to resolve reference ‘Microsoft.EntityFrameworkCore.Sqlite’. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Unable to resolve reference ‘Microsoft.EntityFrameworkCore.Relational’. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Do I have to manually download all dll files that are present in the NuGet Package for this to work? Any help would be highly appreciated!