Bit of a weird one this. Checked everything in working last night and went to bed as you do. Now at this point I will mention I am a team of one and there is no one else working on this!
Got up this morning to pick up where I left of and now I get System.StackOverFlow
exception in ModelContainer.cs
. Absolutely nothing has changed from last night.
The Dev PC is Windows 11. Database server is Windows Server 2019 running SQL Server 2022. Visual Studio 2022. Everything is fully patched to the latest versions.
This is the call I am making to the API:
A screenshot showing exactly where the error is thrown:
And this is the code for the thing I am calling (the GET) :
namespace Phoenix.Server.Web.Api.Base.Controllers
{
[RoutePrefix("api/account")]
public class AccountController : ApiController
{
private AccountService _accountService = new AccountService();
// GET api/account
public string Get()
{
return "The beast is alive!!";
}
// POST api/account/create
[Route("create")]
public string Create([FromBody] AccountCreationFullRequest request)
{
return _accountService.CreateAccount(request);
}
}
}
Text version of the model as requested:
public partial class ModelContainer : DbContext
{
public ModelContainer()
: base("name=ModelContainer")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<AppSetting> AppSettings { get; set; }
public virtual DbSet<County> Counties { get; set; }
public virtual DbSet<Country> Countries { get; set; }
public virtual DbSet<DatabaseVersion> DatabaseVersions { get; set; }
public virtual DbSet<DocumentData> DocumentDatas { get; set; }
public virtual DbSet<DocumentIndex> DocumentIndexes { get; set; }
public virtual DbSet<DocumentType> DocumentTypes { get; set; }
public virtual DbSet<EmailAddress> EmailAddresses { get; set; }
public virtual DbSet<EventLog> EventLogs { get; set; }
public virtual DbSet<EventSource> EventSources { get; set; }
public virtual DbSet<EventType> EventTypes { get; set; }
public virtual DbSet<Log> Logs { get; set; }
public virtual DbSet<Password> Passwords { get; set; }
public virtual DbSet<Pepper> Peppers { get; set; }
public virtual DbSet<Permission> Permissions { get; set; }
public virtual DbSet<Person> Persons { get; set; }
public virtual DbSet<PostalAddress> PostalAddresses { get; set; }
public virtual DbSet<Role> Roles { get; set; }
public virtual DbSet<Salt> Salts { get; set; }
public virtual DbSet<TelephoneNumber> TelephoneNumbers { get; set; }
public virtual DbSet<User> Users { get; set; }
public virtual DbSet<UserSession> UserSessions { get; set; }
public virtual DbSet<UsersToPassword> UsersToPasswords { get; set; }
public virtual DbSet<UserType> UserTypes { get; set; }
}
Last night the beast was alive - this morning its seems to have had a heart attack!
Any help greatly appreciated - there isn't enough coffee in the world for this madness on a Sunday
1条答案
按热度按时间0sgqnhkj1#
You need to check a few things here. You may have not realised it yesterday but there will be an issue before as well if you have not made any code changes.
throw new UnintentionalCodeFirstException();
ModelContainer
for entities and checking which entity is causing this issue. You also need to make sure that you have not accidentally deleted anything from the database. Read the official documentation , you might get some idea of the root cause.