Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Unity 2018 using Entity Framework

Discussion in '2018.1 Beta' started by Linthu, Jan 15, 2018.

  1. Linthu

    Linthu

    Joined:
    Aug 28, 2013
    Posts:
    10
    I have a dll I created using entity framework under .net 4.6.2. Is it a very simple DbContext with a single table. My integration tests passing in a connection string with a Data Source, Database, User Id and Password, and the integration tests.

    When I pull the same dll into unity and run it, I get the following errors which typically lock up Visual Studio as well as Unity.

    Snix_Connect (provider: SNI_PN7, error: 35 - SNI_ERROR_35)
    Snix_Connect (provider: SNI_PN7, error: 40 - SNI_ERROR_40)

    Any suggestions where to look next? Is this even possible?

    Thanks in advance!
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    Does it work in earlier Unity versions, but does not in 2018.1? In this case, if it's a regression, then it's probably from advantage to submit a bug-report, following the advice given in this document.
     
  3. Linthu

    Linthu

    Joined:
    Aug 28, 2013
    Posts:
    10
    I wasn't able to get it to work in either 2017 or 2018. And those were my first and only attempts.
     
  4. Dennin-Dalke

    Dennin-Dalke

    Joined:
    Aug 10, 2014
    Posts:
    25
    So I guess this isn't the right place to post your issue.
     
  5. Linthu

    Linthu

    Joined:
    Aug 28, 2013
    Posts:
    10
    Well, I posted here because its regarding a new feature of 2017/2018 (.net 4.6.2 experimental). Why is this the wrong place, where is a better place?

    Thanks for the advice
     
  6. joncham

    joncham

    Unity Technologies

    Joined:
    Dec 1, 2011
    Posts:
    276
    Please file a bug. It may also be worth trying this in a console application using Mono framework; that narrows it down to a Unity issue or a Mono issue. Also note we don't support *all* of the .NET Framework. The API surface is very large and not designed with cross platform compatibility in mind. I hope to give a better idea of what is expected to work in the future.
     
    MechEthan likes this.
  7. Linthu

    Linthu

    Joined:
    Aug 28, 2013
    Posts:
    10
    Awesome, thank you for the response and clarification! I will give it a whirl in a Mono Console and submit a report with better info.
     
  8. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Thanks Linthu. When you do, please also post the case # in here.
     
  9. Linthu

    Linthu

    Joined:
    Aug 28, 2013
    Posts:
    10
    I have a conflict tonight, so I cant work on the mono console test until probably Wednesday. Do you want the bug submitted without it, or wait until I do that test.

    Also, would netstandard 2 be a more stable choice? (based on the cross platform comment above)

    Linthu
     
  10. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    With it would be preferable.
     
  11. Linthu

    Linthu

    Joined:
    Aug 28, 2013
    Posts:
    10
    I was able to generate an error under Mono with the same couple of lines of code. It works in Visual Studio with .net 4.6.2, but doesn't in Mono. So, it sounds like a mono issue. However, the error message we get in mono is not being clearly bubbled up through unity.

    Case #989139

    I think the next step on my end will be to create a netstandard version and see if there is any difference.

    Thanks for the guidance!
     
  12. VordaRR

    VordaRR

    Joined:
    Oct 14, 2017
    Posts:
    9
    Hi, i had same problems as you, but managed to resolve it in both using both .NET 4.6 and .NET Standard profiles.
    I resolved it by placing all the needed references in the Assets folder (it's kinda of a pain because unity only gives you an error that it couldnt load a .dll - but not the dll name, so you have to scan Entity Framework dll-s to find references that are not in the Unity installation folder.

    After that i think errors you linked started popping up only because Mono System.Data.SqlClient can't parse all of the connection string formats so i replaced my connection string i usually use in EF Core with a simpler older format: Data Source={SQL_INSTANCE_NAME};user id={SQL_USERNAME};password={SQL_PASS};Initial Catalog={DB:NAME};

    After that everything started working, and i'm now able to share the same code between for example a ASP.NET Core App & Unity3d

    GJ Unity team :)
     
  13. Linthu

    Linthu

    Joined:
    Aug 28, 2013
    Posts:
    10
    Thank you very much for the suggestions. I created a netstandard 2.0 version of my dll and copied all dll's over (based on packages file) and updated the connection string format to the old one, like yours. Unfortunately, I still was not able to get it to work.
     
    Foriero likes this.
  14. VordaRR

    VordaRR

    Joined:
    Oct 14, 2017
    Posts:
    9
    Very likely just dll issues... So i had to dig in to EntityFramework and get all internal references too... This is my DLL list copied over from the nuget cache (you're probably missing one of the System. dlls or the Remotion dll):

    System.Collections.Immutable
    Sytem.Collections.DiagnosticSource
    System.Interactive.Async
    Remotion.Linq
    Microsoft.Extensions.Primitive
    Microsoft.Extensions.Options
    Microsoft.Extensions.Logging.Abstractions
    Microsoft.Extensions.Logging
    Microsoft.Extensions.DependencyInjection.Abstractions
    Microsoft.Extensions.DependencyInjection
    Microsoft.Extensions.Configuration.Abstractions
    Microsoft.Extensions.Caching.Memory
    Microsoft.Extensions.Caching.Abstractions
    Microsoft.EntityFrameworkCore.SqlServer
    Microsoft.EntityFrameworkCore.Relational
    Microsoft.EntityFrameworkCore
     
  15. Linthu

    Linthu

    Joined:
    Aug 28, 2013
    Posts:
    10
    I have been tied up from getting back to this until today. Thank you so much for offering your list of DLL's. I will try this tonight!

    If this works, you will be my hero. ;)
     
  16. Linthu

    Linthu

    Joined:
    Aug 28, 2013
    Posts:
    10
    Well, I double checked and I have exactly the references you listed (I had too many before), and I tested my old style connection string in a console test. But still no luck.

    Of course, I tried to attach to unity so I can inspect the dbcontext to see if any info is in there, studio wont give me the option to attach to unity - and for some reason, studio keeps opening thinking that my scripts are in c# 4 - even though I double checked that build settings are still netstandard 2.0 and 4.6 experimental.

    I will keep messing with this. Maybe the next step is to move my code out of its own dll and see if I can bring it in as scripts in unity directly.
     
  17. VordaRR

    VordaRR

    Joined:
    Oct 14, 2017
    Posts:
    9
    Yeah i bumped to this problem again today after days of it working just fine.... another problem that gives the same cryptic error: I resolved it by enabling my SQL Browser service LOL (seems that the native SQL client - sni.dll - is very messed up in the version that ships with unity)

    About your problem with visual studio.... - i simply couldn't be bothered with VS and the debugger it's so poor it's incredible (i think only one guy is maintaining the debugger) - so... i tried JetBrains Rider - and even they didnt update their plugin for 2018 beta - their debugger works like a charm - immediatly after that i bought a licence and never looked back - am much happier developer now :)