Dear All,
I have a dotnet core 1.1 project running in production. I upgraded it with core 2.0 and keep getting error from the EntityFramework core 2.0 and I don't get any debugger information.

Then I created from scratch a new .net core 2.0 project and regenerated the entity framework using the instructions here
https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db
Then when I run the project and try to query the content of a table in my database I get the same error message.
Regards
Sebastien
I also migrated my project from Core 1.1 to 2.0.
Core 1.1 was working fine but getting the same error in core 2.0 and not get any debugger information.
Hi,
I got the same mistake.
@seb999 Can you let us know which version of VS you are using, and also which versions of the .NET Core SDK are insatalled. Also, what happens if you run the app not in the debugger? What error/exception/message/stack trace do you see, if any?
@seb999 You need Visual Studio 2017 in version 15.3 (the new one). Also you need to update all your NuGet packages to v2.0 and also you need to install .NET Core SDK 2.0 from: https://www.microsoft.com/net/core#windowscmd
Hej,
I have Visual Studio enterprise 2017 Version 15.3.0 (I installed the update package),
I have intalled the .net core SDK 2.0
My .csproj contain only 2.0 packages:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>

If I run the app not in debug mode I got error 502.3 Bad Gateway.
Same issue. Visual studio 15.3.1, all package upgraded to 2.0, dotnet sdk 2.0, dot cli tool all 2.0. It's a critical issue. Everything related to EntityFramework core is not working, however the usermanager and rolemanager is still working well.
Same issue as seb999 with Visual Studio 15.3.1, dotnet sdk 2.0 and all .NET Core packages updated to 2.0!
Check also you .csproj and check if all references are ok.
@seb999 Do you get any more information with the Bad Gateway error? Any call stacks, etc?
It seems unlikely that this is related to EF Core specifically. Does it still repro if you remove EF packages?
Hi Arthur,
It’s working without EF package. I migrated other projects (bit simpler without db or with basic MySql) and it works well.
I got this output :
The thread 0x1dc4 has exited with code 0 (0x0).
An unhandled exception of type 'System.StackOverflowException' occurred in System.Private.CoreLib.dll
Thanks.
I just upgraded to 2.0 without issues. I did find that to get things working I removed all the individual packages and just used the meta package instead.
For what it is worth, this project has been upgraded from 1.0-BETA project.json through to 2.0 with all the hiccups that were (and were not) expected along that journey.
Here my csproj file if it helps in any way. Also note I am using SQL Server in-case there is a problem with the different drivers.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<VersionPrefix>1.2.1</VersionPrefix>
<Version>1.2.1</Version>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="Properties\PublishProfiles\Default.pubxml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="3.0.1" />
<PackageReference Include="NuGet.CommandLine" Version="4.1.0" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
I had to scaffold from the database in an empty project. And replaced all contents of the models-folder for all projects that had efcore contexts.
Edit:
After I did this I can scaffold as normal...
Anyone able to solve this chaos?
Unfortunately, I didn't manage to sort it out.
@seb999 @badyalsk @joelmartinez @Wayne-Mather @DNS-Cihang @mparlak Could one of you attach a project that reproduces the issue so that we can investigate?
@ajcvickers - Unfortunately my solution is for a corporate entity so I cannot supply a solution. Hopefully others who have issues can assist.
@seb999 @badyalsk @mparlak - Silly question, but did you update your Main.cs and Startup.cs as per the upgrade guide?
Update 1: I just had a problem where I re-enabled my DBSeeder in the Configure() function and that broke migrations.
Fixed with help from reference: Unable to create migrations after upgrading to asp.net core 2.0
// New Main
public class Program
{
public static void Main(string[] args)
{
var webHost = BuildWebHost(args);
#region Seeder No Longer Run
//using (var scope = webHost.Services.CreateScope())
//{
// var services = scope.ServiceProvider;
// try
// {
// var dbContext = services.GetRequiredService<ApplicationDbContext>();
// var roleManager = scope.ServiceProvider.GetRequiredService<RoleManager<IdentityRole>>();
// var userManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();
// var task = dbContext.RunDbSeed(userManager, roleManager, new MessageBus(dbContext));
// }
// catch (Exception ex)
// {
// var logger = services.GetRequiredService<ILogger<Program>>();
// logger.LogError(ex, "An error occurred while seeding the database.");
// }
//}
#endregion
webHost.Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
Old Configure() function in Startup.cs:
public void Configure(
IApplicationBuilder app,
IHostingEnvironment env,
ILoggerFactory loggerFactory,
UserManager<ApplicationUser> userManager,
RoleManager<IdentityRole> roleManager,
ApplicationDbContext dbContext
)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
loggerFactory.AddDebug(LogLevel.Trace);
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
#region Seeder No Longer Run
//var t = dbContext.RunDbSeed(userManager, roleManager);
//t.Wait();
#endregion
app.UseStaticFiles();
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(name: "areaRoute",
template: "{area:exists}/{controller=Home}/{action=Index}");
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
New configure() in Startup.cs:
public void Configure (
IApplicationBuilder app,
IHostingEnvironment env,
ILoggerFactory loggerFactory )
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
loggerFactory.AddDebug(LogLevel.Trace);
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(name: "areaRoute",
template: "{area:exists}/{controller=Home}/{action=Index}");
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
and the new constructor in Startup.cs (only if you currently use a property in your startup class)
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
Old Post Data below:
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
and the new constructor in Startup.cs (only if you currently use a property in your startup class)
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
Yes, I already updated Main.cs and Startup.cs classes as per the upgrade guide.
This is a dummy project where i created the EF model based on my existing database with the Scaffolding tool.
Joining the database is a bit complicated, but eventually you can generate the database base on the model. I also tried this approach and it is not working.
Getting error: An unhandled exception of type 'System.StackOverflowException' occurred in System.Private.CoreLib.dll
@Wayne-Mather
My current application is running fine with Microsoft.EntityFrameworkCore.SqlServer version = "1.1.2". But if I upgrade to Microsoft.EntityFrameworkCore.SqlServer version = "2.0.0" and run the application, it gives a StackOverflowException error.
Thanks @seb999 for the project.
@AndriySvyryd Looks like this is a stack overflow in the model validator. Assigning to you to investigate as a high priority.
@seb999 This is caused by a self referencing FK defined on the PK:
C#
entity.HasOne(d => d.Pet)
.WithOne(p => p.InversePet)
.HasForeignKey<PendingExpenseTransfer>(d => d.PetId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_PendingExpenseTransfer_PendingExpenseTransfer");
This would result in a useless relationship, since it would always point to itself.
To fix it add another property, like TransferPetId, to PendingExpenseTransfer and use it for the FK.
Duplicate of #9478
Thanks a lot Andriy for your intervention. I commented out this self reference in the DBContext as well as the property InversePet in the table PendingExpenseTransfer and it works.
Was this self reference reflected in the output or error list?
Hi Johan, on my side it was not visible in the error list.
Hey Guys,
Is there any way to find out the self-referencing FK defined on the PK? so that we can get the list of all chaos entities/self-referencing FK and fix it right away to run the project in EF2.0.
@badyalsk Something like this:
select    s1.name as from_schema
,        o1.Name as from_table
,        s2.name as to_schema
,        o2.Name as to_table
from    sys.foreign_keys fk
inner    join sys.objects o1
on        fk.parent_object_id = o1.object_id
inner    join sys.schemas s1
on        o1.schema_id = s1.schema_id
inner    join sys.objects o2
on        fk.referenced_object_id = o2.object_id
inner    join sys.schemas s2
on        o2.schema_id = s2.schema_id
where      (    s1.name = s2.name
            and    o1.name = o2.name)
Thanks a lot @ErikEJ for sharing query. I just commented out the self-referencing table from the DBContext and it works.
Hi @seb999, @badyalsk, @johanskoldekrans, @joelmartinez, @Wayne-Mather, @DNS-Cihang, @mparlak. We are gathering information on the use of EF Core pre-release builds. You reported this issue shortly after the release of 2.0.0 RTM. It would be really helpful if you could let us know:
Thanks in advance for any feedback. Hopefully this will help us to increase the value of pre-release builds going forward.
I have to host the web sites on IIS and since I couldn't get hold of the
updated server hosting for the previews I had to downgrade which is
extremely frustrating since just have fixed so many bugs since release. And
the strategy to not release those fixes as patches is something I just
can't understand.
On version 1.* when you had another documentation site you could choose the
dev-bransch and download the server hosting files. But it is still scary to
go live with preview versions for production systems.
So patch up, test and release would be something I would appreciate more.
ATB,
Johan
2017-09-12 19:55 GMT+02:00 Arthur Vickers notifications@github.com:
Hi @seb999 https://github.com/seb999, @badyalsk
https://github.com/badyalsk, @johanskoldekrans
https://github.com/johanskoldekrans, @joelmartinez
https://github.com/joelmartinez, @Wayne-Mather
https://github.com/wayne-mather, @DNS-Cihang
https://github.com/dns-cihang, @mparlak https://github.com/mparlak.
We are gathering information on the use of EF Core pre-release builds. You
reported this issue shortly after the release of 2.0.0 RTM. It would be
really helpful if you could let us know:
- Did you consider testing your code against the pre-release builds?
- Was there anything blocking you from using pre-release builds?
- What do you think could make it easier for you to use pre-release
builds in the future?Thanks in advance for any feedback. Hopefully this will help us to
increase the value of pre-release builds going forward.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/aspnet/EntityFrameworkCore/issues/9462#issuecomment-328932116,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AR1Ti2oGJ4dS1iCbEYFlgI9_SrY8txGYks5shsWJgaJpZM4O7UU7
.
--
Johan Sköldekrans
IT
Telefon +46 8 463 8000 <+4684638000>
Direkt +46 8 463 8029 <+4684638029>
Mobil +0760856512
Erik Penser Bank
Apelbergsgatan 27
Box 7405
103 91 Stockholm
--
www.penser.se
Disclaimer: www.penser.se/disclaimer
Hi @ajcvickers.
I have tested now. No problem in working.
Thanks
Hi Arthur, I actually installed the pre-release. The process was strange to install another Visual Studio version. When I opened my project, I started the migration and got lot of error to fix before being able to run the project. I rollback and decided to build a new project and migrate only the EF and got this issue. I stopped here.
When the RTM was release, and got the same problem I finally try to get some help and opened the issue on Github.
So I would say as it was a pre-release I didn't really try to go further and decided to wait the RTM. It was also the first time I reported a problem to the community on Github. I didn't want to bother you with my local issue. So sorry about that, maybe I have a wrong approach and you prefer to have lot of feedback even « imaginary issue » that are in fact user mistake. What do you think ?
@seb999 Thanks for the feedback. The process of getting the 2.0 pre-releases working with VS was very difficult; this is something that hopefully will get better going forward. Also, our documentation in this area (tooling/migrations) has some holes. Hopefully with better documentation on what should work and pre-release builds that are easier to use you won't run into the same kind of issue in the future and it will be more clear which issues it is worth filing. Thanks again for the feedback.
@ajcvickers I tried the pre-release version on another machine but with so many errors at that time I decided to wait until 2.0 was nearer to RTM. As my solution had come from the DNX days, I thought it was best to wait until 2.0 to save all the problems I had when moving through all the alphas and betas for ASP.NET vNext.
@Wayne-Mather Thanks for the feedback; much appreciated.
Hi,
I just ran into the same issue upgrading an asp.net project from 1.0 to 2.0 --- StackOverflowException with complete website shutdown as soon as a dbset is touched either via code or quick watch.
My db model is pretty complex so finding the specific entity was going to time consuming but @ErikEJ SQL found the bad table right away!!!!! Thanks that saved a whole bunch of headache.
@fspataro We upgraded to the October-patch and haven’t had any problems since.
Hi @johanskoldekrans --- which patch are you referring to? I just started this upgrade with a clean install of VS2017 and pulled all the updates and patches the VS showed me. I did notice VS 15.4.4 today --- currently on 15.4.3.
Try this https://github.com/dotnet/core/blob/master/release-notes/download-archive.md
15 nov. 2017 kl. 20:41 skrev Fred Spataro notifications@github.com:
Hi @johanskoldekrans --- which patch are you referring to? I just started this upgrade with a clean install of VS2017 and pulled all the updates and patches the VS showed me. I did notice VS 15.4.4 today --- currently on 15.4.3.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
--
www.penser.se
Disclaimer: www.penser.se/disclaimer
@johanskoldekrans thanks!