Jump to content

Recommended Posts

Posted (edited)

Hello everyone!
I've got some errors with references to assemblies, but I've managed to solve the most of them except one with Entity Framework Core.

So, the problem is:

CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

I added the Microsoft.EntityFrameworkCore.dll reference to my resource, and then restarted the server. I got bunch of this error:

The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

If I keep this reference, then I get just these errors, nothing else. So I decided to delete this reference, and add MySql.Data.EntityFrameworkCore.dll and Microsoft.EntityFrameworkCore.Relational.dll. The results are the following:

CS0246: The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)

CS0246: The type or namespace name 'DbContextOptionsBuilder' could not be found (are you missing a using directive or an assembly reference?)

CS0246: The type or namespace name 'DbSet<>' could not be found (are you missing a using directive or an assembly reference?)
  
CS0012: The type 'DbContextOptionsBuilder' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.EntityFrameworkCore, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

I don't know what should I do now. I've never used .NET Core, so if anyone could help me a bit, it would be awasome.
Thanks,
manaszon!

Edited by manaszon
Posted (edited)

There were several problems with my project, but it is solved now thanks to @xForcer.

So, if you have a new project, you will need these packages to use Entity Framework Core:
- Microsoft.EntityFrameworkCore
- Microsoft.EntityFrameworkCore.Tools
- Pomelo.EntityFrameworkCore.MySql
- Pomelo.EntityFrameworkCore.MySql.Design

You will have to copy the .dll files into RAGEMP\server-files\bridge\runtime folder and into RAGEMP\server-files\bridge\resources\<your resource> folder too. After that you will have to add migrations, and if everything goes well then you are done.

MS DOCS - Migrations (EF core)

Edited by manaszon
  • Like 1
  • 6 months later...
Posted

Hey sorry for necroing but I think it is on topic. I am using Entity Framework 6.2.0 but I receive a warning about .NetFramework need being 4.6.1 instead of 2.0 that it is used (currently) for the server.

How do you fix this issue?

 

go this exception on debug.

 

System.TypeInitializationException: 'The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.'

FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. 

also this stacktrace on server console.

  at new System.Data.Entity.Internal.AppConfig()
   at static System.Data.Entity.Internal.AppConfig()
   --- End of inner exception stack trace ---
   at new System.Data.Entity.Internal.LazyInternalConnection(DbContext context, string nameOrConnectionString)
   at new System.Data.Entity.DbContext()
   at new RageMp.DataBase.ServerContext()
   at void RageMp.Main.OnResourceStart() in C:\Users\Rui\source\repos\RageMp\RageMp\main.cs:line 16
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at GTANetworkInternals.ScriptingEngine.InvokeVoidMethod(String method, Object[] args)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at GTANetworkInternals.EventHandler.ParseEx(Event _event, ScriptingEngine engine, Object[] arguments)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at GTANetworkInternals.GameServer.StartResource(String resourceName, String parent)

 

Posted

Need to use: Microsoft.EntityFrameworkCore.

EF6 is for normal .net, not core.

Posted
On 12/15/2018 at 12:35 AM, horseyhorsey said:

Need to use: Microsoft.EntityFrameworkCore.

EF6 is for normal .net, not core.

Thanks for the help, but I still got a problem. I could make the migrations and create the db, but I still got an expection.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. O sistema não conseguiu localizar o ficheiro especificado.
   at EntityFrameworkServicesBuilder Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.TryAddCoreServices()
   at bool Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.ApplyServices(IDbContextOptions options, ServiceCollection services)
   at IServiceProvider Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.GetOrAdd(IDbContextOptions options, bool providerRequired)+(long k) => { }
   at TValue System.Collections.Concurrent.ConcurrentDictionary<TKey, TValue>.GetOrAdd(TKey key, Func<TKey, TValue> valueFactory)
   at IServiceProvider Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.GetOrAdd(IDbContextOptions options, bool providerRequired)
   at new Microsoft.EntityFrameworkCore.DbContext(DbContextOptions options)
   at new RageMpServer.ServerContext()
   at void RageMpServer.Main.OnResourceStart() in C:\Users\Rui\source\repos\RageMpServer\RageMpServer\Main.cs:line 13
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at GTANetworkInternals.ScriptingEngine.InvokeVoidMethod(String method, Object[] args)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at GTANetworkInternals.EventHandler.ParseEx(Event _event, ScriptingEngine engine, Object[] arguments)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at GTANetworkInternals.GameServer.StartResource(String resourceName, String parent)

got this expection when compiling, on the line below.

 using (var db = new ServerContext())

I have the db on the resources directory.

 

Posted

You'll have to play around with getting some missing / diff versioned files from your build into the runtime folder.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...