I starting to learn changes in ASP.NET 5(vNext) and cannot find how to get IServiceProvider, for example in \"Model\"\'s method
public class Entity
{
publ
Do not use GetService()
The difference between GetService and GetRequiredService is related with exception.
GetService() returns null if a service does not exist. GetRequiredService() will throw exception.
public static class ServiceProviderServiceExtensions
{
public static T GetService(this IServiceProvider provider)
{
return (T)provider.GetService(typeof(T));
}
public static T GetRequiredService(this IServiceProvider provider)
{
return (T)provider.GetRequiredService(typeof(T));
}
}