C# EF 6 + Sql Server issue

Hi.

I can properly connect to SqlServer using EF6 with DbContext.

However, whenever i try to interact with any of DB items i get an exception for missing System.Data.OracleClient.

Adding it to resources just gives an error for “invalid connection string”, because as I suppose it mistakes it for OracleConnection?

To my knoweledge, it shouldn’t be happening because I don’t even use OracleClient as db provider?

DbContext code:

 public static ApocalypseDbContext Instance = new ApocalypseDbContext();




        public ApocalypseDbContext() : base("Data Source=DESKTOP-TRRN8HR;Initial Catalog=apocalypse-rp;Integrated Security=True")
        {

        }

        public DbSet<CharacterModel> Characters { get; set; }

CharModel:

   class CharacterModel
    {



        [Key]

        public int ID { get; set; }

        [Required]
        public string SteamID { get; set; }

        [Required]
        public string FirstName { get; set; }

        [Required]
        public string LastName { get; set; }
        [Required]
        public string Faction { get; set; }



    }

Running this code gives me the error:

  try
            {



                ApocalypseDbContext.Instance.Characters.ToList(); // However, whenever i actually try to add to database , read from it or remove something, it gives me that strange error.

                ApocalypseDbContext.Instance.SaveChanges(); // Can actually run it without any errors

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.InnerException.ToString());
            }

            Debug.WriteLine("Done saving changes.");

App.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

Can I actually get it to work without using any unnecesary stuff?

Add System.Data.OracleClient into next to your ressource. After that I get a this error :

It’s a 10054 exception “connection was forcibly closed by the remote host”. Unfortunatly, it’s misleading, it can be an unreacheable host which is more certain since I took my code and put it inside a simple C# console app and it works : aka connecting on the MSSQL server.

Maybe FiveM refuse UDP connection outside its CLR/environment anyone have an idea about this error ?

(I’ll try Wireshark to see if anything goes out & try a simple UDP connection ?)

Don’t bother, its not compatible with the framework.

If you want to use EF, go ahead with ef core 2.0.

It works fine on server side scripts.

Which version of EF Core ? When I try version 2.0 it says I can’t with NET Framerwork 4.5.2, should I pass my dll to Net Core ?

Make sure your class lib targets net standard 2.0