Singletons
DatabaseContext
Injects the same DatabaseContext instance.
We recommend using this only if there is no available API method for your use-case.
If you haven't used Entity Framework previously we recommend checking out the official documentation before diving into it.
Note that due to some FiveM limitations we can only use Entity Framework Core version 3.1.26, so make sure you're reading the correct documentation.
Usage in an addon:
using CitizenFX.Core;
using FivePD.Server.API;
using FivePD.Server.Interfaces;
namespace MyAwesomeAddon;
public class MyAwesomeExtension : IExtension
{
private readonly DatabaseContext _databaseContext;
public MyAwesomeExtension(DatabaseContext databaseContext)
{
this._databaseContext = databaseContext;
}
public Task OnStarted()
{
return Task.FromResult(0);
}
public Task OnStopped()
{
return Task.FromResult(0);
}
}