Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackOverflow exception when using Fluent API HasName in preview7 #21786

Closed
brice-fromentin opened this issue Jul 25, 2020 · 1 comment
Closed

Comments

@brice-fromentin
Copy link

In preview 7, my DbContext throw a Stackoverflow exception, after digging it's the HasName method that throws the exception. The column has a unique constraints.

Connect to DB and execute a query

DBContext Extract :

            modelBuilder.Entity<Utilisateur>(entity =>
            {
                entity.HasIndex(e => e.Login)
                    .HasName("AK_Utilisateur_Login");
                    .IsUnique();

                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");

                entity.Property(e => e.DateCreation).HasDefaultValueSql("(getdate())");

                entity.HasOne(d => d.Service)
                    .WithMany(p => p.Utilisateurs)
                    .HasForeignKey(d => d.IdService)
                    .HasConstraintName("FK_Utilisateur_Service");
            });

Model :

public partial class Utilisateur
    {
        public Utilisateur()
        {
            UtilisateurGroupes = new HashSet<UtilisateurGroupe>();
        }

        [Key]
        public Guid Id { get; set; }
        [Column(TypeName = "datetime")]
        public DateTime DateCreation { get; set; }
        public Guid? UtilisateurCreation { get; set; }
        [Column(TypeName = "datetime")]
        public DateTime? Modification { get; set; }
        public Guid? UtilisateurModification { get; set; }
        [Required]
        [StringLength(256)]
        public string Login { get; set; }
        [Required]
        [MaxLength(32)]
        public byte[] MotDePasse { get; set; }
        public bool EstBloque { get; set; }
        public bool DoitReinitialiser { get; set; }
        [Column(TypeName = "datetime")]
        public DateTime? DateDebutMotDePasse { get; set; }
        public short? DureeMotDePasse { get; set; }
        [Required]
        [StringLength(32)]
        public string Prenom { get; set; }
        [StringLength(32)]
        public string Prenom2 { get; set; }
        [StringLength(32)]
        public string Prenom3 { get; set; }
        [Required]
        [StringLength(64)]
        public string Nom { get; set; }
        [Required]
        [StringLength(256)]
        public string Mel { get; set; }
        [StringLength(20)]
        public string Telephone { get; set; }
        [StringLength(20)]
        public string Fax { get; set; }
        [Column(TypeName = "datetime")]
        public DateTime? DateDebutValidite { get; set; }
        public short? DureeValidite { get; set; }
        public Guid? IdService { get; set; }

        [ForeignKey(nameof(IdService))]
        [InverseProperty("Utilisateurs")]
        public virtual Service Service { get; set; }
        [InverseProperty(nameof(UtilisateurGroupe.Utilisateur))]
        public virtual ICollection<UtilisateurGroupe> UtilisateurGroupes { get; set; }
    }

Further technical details

EF Core version: preview 7
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 5.0
Operating system: Windows 10
IDE: Visual Studio 2019 16.7 preview 5

@AndriySvyryd
Copy link
Member

Duplicate of #21734

@AndriySvyryd AndriySvyryd marked this as a duplicate of #21734 Jul 25, 2020
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants