Yesterday I started to learn ASP.NET 5 MVC 6 with Entity Framework 7.0.0-rc1-final
and I followed this tutorial : Link. The problem is when I run it it throws a NullPointerException on this function:
if (serviceProvider.GetService<IRelationalDatabaseCreator>().Exists())
{//adding some entities }
My connection string is: "Server=(localdb)\\MSSQLLocalDB; Database=Test; Trusted_Connection=True; MultipleActiveResultSets=true"
In Startup.cs I have this code:
public void ConfigureServices(IServiceCollection services)
{
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<Models.HRPContext>(options =>
{
options.UseSqlServer(Configuration["Data:ConnectionString"]);
});
.......
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
Utils.AddSampleData.Initialize(app.ApplicationServices);
......
}
The database Test is not yet created. Is there someone who solved this exception? Thanks