Monday, July 30, 2018

Introducing FOREIGN KEY constraint 'FK_dbo.Customers_dbo.States_StateId' on table 'Customers'.

when you getting Error in entity Framework  :-

 Introducing FOREIGN KEY constraint 'FK_dbo.Customers_dbo.States_StateId' on table 'Customers'...

Solution :-

Add this method in the context database class:
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
        }