Base solution for your next web application

Activities of "nipunjoshi"

I have downloaded the latest version of the ASP.net Zero (V1.7).But when I compile it,it shows below mentioned errors on the Test project.

And all the references of the Test project are shown as below.Could you tell me how to sort out this issue ? Thanks in advance.

Hi, I have done that.But now it gives 49 errors as shown below (but now no reference errors as I mentioned on the above post).Could you tell me why ?

Yep,Thanks a lot.Now it works :)

I have upgraded to the latest version (1.7).Now it gives below mentioned error when I try to load the app.Could you tell me why ? Thanks in advance.

Error url : [https://docs.angularjs.org/error/$injector/modulerr?p0=app&p1=Error:%20%5B$injector:modulerr%5D%20http:%2F%2Ferrors.angularjs.org%2F1.4.8%2F$injector%2Fmodulerr%3Fp0%3Doc.lazyLoad%26p1%3DError%253A%2520%255B%2524injector%253Anomod%255D%2520http%253A%252F%252Ferrors.angularjs.org%252F1.4.8%252F%2524injector%252Fnomod%253Fp0%253Dxeditable%250A%2520%2520%2520%2520at%2520Error%2520(native)%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A6240%252FScripts%252Fangular.min.js%253A6%253A416%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A6240%252FScripts%252Fangular.min.js%253A24%253A186%250A%2520%2520%2520%2520at%2520b%2520(http%253A%252F%252Flocalhost%253A6240%252FScripts%252Fangular.min.js%253A23%253A251)%250A%2520%2520%2520%2520at%2520Object.module%2520(http%253A%252F%252Flocalhost%253A6240%252FScripts%252Fangular.min.js%253A23%253A494)%250A%2520%2520%2520%2520at%2520u%2520(http%253A%252F%252Flocalhost%253A6240%252Flibs%252Fangular-ocLazyLoad%252FocLazyLoad.min.js%253A8%253A2925)%250A%2520%2520%2520%2520at%2520Object.n%2520%255Bas%2520forEach%255D%2520(http%253A%252F%252Flocalhost%253A6240%252FScripts%252Fangular.min.js%253A7%253A333)%250A%2520%2520%2520%2520at%2520u%2520(http%253A%252F%252Flocalhost%253A6240%252Flibs%252Fangular-ocLazyLoad%252FocLazyLoad.min.js%253A8%253A2994)%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A6240%252Flibs%252Fangular-ocLazyLoad%252FocLazyLoad.min.js%253A8%253A3048%250A%2520%2520%2520%2520at%2520Object.n%2520%255Bas%2520forEach%255D%2520(http%253A%252F%252Flocalhost%253A6240%252FScripts%252Fangular.min.js%253A7%253A333)%0A%20%20%20%20at%20Error%20(native)%0A%20%20%20%20at%20http:%2F%2Flocalhost:6240%2FScripts%2Fangular.min.js:6:416%0A%20%20%20%20at%20http:%2F%2Flocalhost:6240%2FScripts%2Fangular.min.js:38:391%0A%20%20%20%20at%20n%20(http:%2F%2Flocalhost:6240%2FScripts%2Fangular.min.js:7:333)%0A%20%20%20%20at%20g%20(http:%2F%2Flocalhost:6240%2FScripts%2Fangular.min.js:37:488)%0A%20%20%20%20at%20http:%2F%2Flocalhost:6240%2FScripts%2Fangular.min.js:38:134%0A%20%20%20%20at%20n%20(http:%2F%2Flocalhost:6240%2FScripts%2Fangular.min.js:7:333)%0A%20%20%20%20at%20g%20(http:%2F%2Flocalhost:6240%2FScripts%2Fangular.min.js:37:488)%0A%20%20%20%20at%20eb%20(http:%2F%2Flocalhost:6240%2FScripts%2Fangular.min.js:41:249)%0A%20%20%20%20at%20c%20(http:%2F%2Flocalhost:6240%2FScripts%2Fangular.min.js:19:463])

Here it shows the error :

This is my whole app.js file.

/* 'app' MODULE DEFINITION */
var appModule = angular.module("app", [
    "ui.router",
    "ui.bootstrap",
    'ui.utils',
    "ui.jq",
    'ui.grid',
    'ui.grid.pagination',
    "oc.lazyLoad",
    "ngSanitize",
    'angularFileUpload',
    'daterangepicker',
    'xeditable',
    'abp'
]);

/* LAZY LOAD CONFIG */

/* This application does not define any lazy-load yet but you can use $ocLazyLoad to define and lazy-load js/css files.
 * This code configures $ocLazyLoad plug-in for this application.
 * See it's documents for more information: https://github.com/ocombe/ocLazyLoad
 */
appModule.config(['$ocLazyLoadProvider', function ($ocLazyLoadProvider) {
    $ocLazyLoadProvider.config({
        cssFilesInsertBefore: 'ng_load_plugins_before', // load the css files before a LINK element with this ID.
        debug: false,
        events: true,
        modules: []
    });
}]);

/* THEME SETTINGS */
App.setAssetsPath(abp.appPath + 'metronic/assets/');
appModule.factory('settings', ['$rootScope', function ($rootScope) {
    var settings = {
        layout: {
            pageSidebarClosed: false, // sidebar menu state
            pageContentWhite: true, // set page content layout
            pageBodySolid: false, // solid body color state
            pageAutoScrollOnLoad: 1000 // auto scroll to top on page load
        },
        layoutImgPath: App.getAssetsPath() + 'admin/layout4/img/',
        layoutCssPath: App.getAssetsPath() + 'admin/layout4/css/',
        assetsPath: abp.appPath + 'metronic/assets',
        globalPath: abp.appPath + 'metronic/assets/global',
        layoutPath: abp.appPath + 'metronic/assets/layouts/layout4'
    };

    $rootScope.settings = settings;

    return settings;
}]);

/* ROUTE DEFINITIONS */

appModule.config([
    '$stateProvider', '$urlRouterProvider',
    function ($stateProvider, $urlRouterProvider) {

        // Default route (overrided below if user has permission)
        $urlRouterProvider.otherwise("/welcome");

        //Welcome page
        $stateProvider.state('welcome', {
            url: '/welcome',
            templateUrl: '~/App/common/views/welcome/index.cshtml'
        });

        //COMMON routes

        if (abp.auth.hasPermission('Pages.Administration.Roles')) {
            $stateProvider.state('roles', {
                url: '/roles',
                templateUrl: '~/App/common/views/roles/index.cshtml',
                menu: 'Administration.Roles'
            });
        }

        if (abp.auth.hasPermission('Pages.Administration.Users')) {
            $stateProvider.state('users', {
                url: '/users',
                templateUrl: '~/App/common/views/users/index.cshtml',
                menu: 'Administration.Users'
            });
        }

        if (abp.auth.hasPermission('Pages.Administration.Languages')) {
            $stateProvider.state('languages', {
                url: '/languages',
                templateUrl: '~/App/common/views/languages/index.cshtml',
                menu: 'Administration.Languages'
            });

            if (abp.auth.hasPermission('Pages.Administration.Languages.ChangeTexts')) {
                $stateProvider.state('languageTexts', {
                    url: '/languages/texts/:languageName?sourceName&baseLanguageName&targetValueFilter&filterText',
                    templateUrl: '~/App/common/views/languages/texts.cshtml',
                    menu: 'Administration.Languages'
                });
            }
        }

        if (abp.auth.hasPermission('Pages.Administration.AuditLogs')) {
            $stateProvider.state('auditLogs', {
                url: '/auditLogs',
                templateUrl: '~/App/common/views/auditLogs/index.cshtml',
                menu: 'Administration.AuditLogs'
            });
        }

        if (abp.auth.hasPermission('Pages.Administration.OrganizationUnits')) {
            $stateProvider.state('organizationUnits', {
                url: '/organizationUnits',
                templateUrl: '~/App/common/views/organizationUnits/index.cshtml',
                menu: 'Administration.OrganizationUnits'
            });
        }

        //HOST routes

        $stateProvider.state('host', {
            'abstract': true,
            url: '/host',
            template: '<div ui-view class="fade-in-up"></div>'
        });

        if (abp.auth.hasPermission('Pages.Tenants')) {
            $urlRouterProvider.otherwise("/host/tenants"); //Entrance page for the host
            $stateProvider.state('host.tenants', {
                url: '/tenants',
                templateUrl: '~/App/host/views/tenants/index.cshtml',
                menu: 'Tenants'
            });
        }

        if (abp.auth.hasPermission('Pages.Editions')) {
            $stateProvider.state('host.editions', {
                url: '/editions',
                templateUrl: '~/App/host/views/editions/index.cshtml',
                menu: 'Editions'
            });
        }

        if (abp.auth.hasPermission('Pages.Administration.Host.Settings')) {
            $stateProvider.state('host.settings', {
                url: '/settings',
                templateUrl: '~/App/host/views/settings/index.cshtml',
                menu: 'Administration.Settings.Host'
            });
        }

        //TENANT routes

        $stateProvider.state('tenant', {
            'abstract': true,
            url: '/tenant',
            template: '<div ui-view class="fade-in-up"></div>'
        });

        if (abp.auth.hasPermission('Pages.Tenant.Dashboard')) {
            $urlRouterProvider.otherwise("/tenant/dashboard"); //Entrace page for a tenant
            $stateProvider.state('tenant.dashboard', {
                url: '/dashboard',
                templateUrl: '~/App/tenant/views/dashboard/index.cshtml',
                menu: 'Dashboard.Tenant'
            });
        }

        if (abp.auth.hasPermission('Pages.Administration.Tenant.Settings')) {
            $stateProvider.state('tenant.settings', {
                url: '/settings',
                templateUrl: '~/App/tenant/views/settings/index.cshtml',
                menu: 'Administration.Settings.Tenant'
            });
        }

        if (abp.auth.hasPermission('Pages.Tenant.PropertyManagement')) {
            $stateProvider.state('tenant.propertymanagement', {
                url: '/propertymanagement',
                templateUrl: '~/App/tenant/views/propertymanagement/index.cshtml',
                menu: 'PropertyManagement.Tenant'
            });
        }

        $stateProvider.state('tenant.imports', {
            url: '/imports',
            templateUrl: '~/App/tenant/views/imports/index.cshtml',
            menu: 'Imports'
        });

        $stateProvider.state('tenant.propertyListingsReport', {
            url: '/propertyListingsReport',
            templateUrl: '~/App/tenant/views/reports/propertyListings.cshtml',
            menu: 'PropertyListingsReport.Tenant'
        });

        $stateProvider.state('tenant.PaymentReceived', {
            url: '/PaymentReceived',
            templateUrl: '~/App/tenant/views/reports/bpoReports/paymentReceived.cshtml',
            menu: 'PaymentReceived.Tenant'
        });

        $stateProvider.state('tenant.BankReport', {
            url: '/BankReport',
            templateUrl: '~/App/tenant/views/reports/bpoReports/bankReport.cshtml',
            menu: 'BankReport.Tenant'
        });

        $stateProvider.state('tenant.OwnerInformation', {
            url: '/OwnerInformation',
            templateUrl: '~/App/tenant/views/reports/researchInformation/ownerInformation.cshtml',
            menu: 'OwnerInformation.Tenant'
        });

        $stateProvider.state('tenant.DriveByRequested', {
            url: '/DriveByRequested',
            templateUrl: '~/App/tenant/views/reports/researchInformation/driveByRequested.cshtml',
            menu: 'DriveByRequested.Tenant'
        });

        $stateProvider.state('tenant.PotentialPropertiesToConsider', {
            url: '/PotentialPropertiesToConsider',
            templateUrl: '~/App/tenant/views/reports/researchInformation/potentialPropertiesToConsider.cshtml',
            menu: 'PotentialPropertiesToConsider.Tenant'
        });

        $stateProvider.state('tenant.BankListUpcoming', {
            url: '/BankListUpcoming',
            templateUrl: '~/App/tenant/views/reports/researchInformation/bankListUpcoming.cshtml',
            menu: 'BankListUpcoming.Tenant'
        });

        $stateProvider.state('tenant.AttorneyForBankUpcoming', {
            url: '/AttorneyForBankUpcoming',
            templateUrl: '~/App/tenant/views/reports/researchInformation/attorneyForBankUpcoming.cshtml',
            menu: 'AttorneyForBankUpcoming.Tenant'
        });

        $stateProvider.state('tenant.UpcomingForeclosureSalesAll', {
            url: '/UpcomingForeclosureSalesAll',
            templateUrl: '~/App/tenant/views/reports/upcomingForeclosureSales/upcomingForeclosureSalesAll.cshtml',
            menu: 'UpcomingForeclosureSalesAll.Tenant'
        });

        $stateProvider.state('tenant.UpcomingForeclosureSalesPriority1List', {
            url: '/UpcomingForeclosureSalesPriority1List',
            templateUrl: '~/App/tenant/views/reports/upcomingForeclosureSales/upcomingForeclosureSalesPriority1List.cshtml',
            menu: 'UpcomingForeclosureSalesPriority1List.Tenant'
        });

        $stateProvider.state('tenant.UpcomingForeclosureSalesByAgent', {
            url: '/UpcomingForeclosureSalesByAgent',
            templateUrl: '~/App/tenant/views/reports/upcomingForeclosureSales/UpcomingForeclosureSalesByAgent.cshtml',
            menu: 'UpcomingForeclosureSalesByAgent.Tenant'
        });

        $stateProvider.state('tenant.BankEvaluation', {
            url: '/BankEvaluation',
            templateUrl: '~/App/tenant/views/reports/reports/bankEvaluation.cshtml',
            menu: 'BankEvaluation.Tenant'
        });

        $stateProvider.state('tenant.AttorneyEvaluation', {
            url: '/AttorneyEvaluation',
            templateUrl: '~/App/tenant/views/reports/reports/attorneyEvaluation.cshtml',
            menu: 'AttorneyEvaluation.Tenant'
        });
    }
]);

appModule.run(["$rootScope", "settings", "$state", function ($rootScope, settings, $state) {
    $rootScope.$state = $state;
    $rootScope.$settings = settings; 

    $rootScope.safeApply = function (fn) {
        var phase = this.$root.$$phase;
        if (phase == '$apply' || phase == '$digest') {
            if (fn && (typeof (fn) === 'function')) {
                fn();
            }
        } else {
            this.$apply(fn);
        }
    };
}]);

Hi, Yes,You're correct.First issue was a permission issue and the second issue was I have overwritten the script files.Now both are working fine. But now I have another issue. Please see that too.Thanks.

Note : This is happening only on the Home page.

Question

Hi, Could you tell me how to add import iconto my app ? There is no such icon on this file : \simple-line-icons.css Thanks.

I have written my first test case.But unfortunately it gives below mentioned exception :cry: Could you tell me why ? Thanks.

Test case :

public class AcquisitionTypeAppServiceTests : AppTestBase
    {
        private readonly IAcquisitionTypeAppService _acquisitionTypeAppService;

        public AcquisitionTypeAppServiceTests()
        {
            _acquisitionTypeAppService = Resolve<IAcquisitionTypeAppService>();
        }

        [Fact]
        public async Task Test_GetAllAcquisitionTypesAsync()
        {
            //Act
            var acquisitionTypes = await _acquisitionTypeAppService.GetAllAcquisitionTypesAsync();

            //Assert
            acquisitionTypes.Items.Count.ShouldBe(5);
        }


    }

Exception :

Test Name:	IP.Tests.AcquisitionTypes.AcquisitionTypeAppServiceTests.Test_GetAllAcquisitionTypesAsync
Test FullName:	 IP.Tests.AcquisitionTypes.AcquisitionTypeAppServiceTests.Test_GetAllAcquisitionTypesAsync
Test Source:	\Tests\IP.Tests\AcquisitionTypes\AcquisitionTypeAppServiceTests.cs : line 19
Test Outcome:	Failed
Test Duration:	0:00:00.001

Result Message:	
System.Data.Entity.Infrastructure.DbUpdateException : An error occurred while updating the entries. See the inner exception for details.
---- System.Data.Entity.Core.UpdateException : An error occurred while updating the entries. See the inner exception for details.
-------- System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
------------ NMemory.Exceptions.ForeignKeyViolationException : Foreign key violation [IpProperties :: CountyId]. The key value [3] does not exists in the referenced table [IpCounties :: Id].. Error code: RelationError
Result StackTrace:	
at System.Data.Entity.Internal.InternalContext.SaveChanges()
   at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
   at Abp.EntityFramework.AbpDbContext.SaveChanges()
   at Joshi.IP.Migrations.Seed.InitialPropertiesCreator.Create() in d:\Freelance Work\Nipun-SPA\SPA\island\Joshi.IP.EntityFramework\Migrations\Seed\InitialPropertiesCreator.cs:line 111
   at Joshi.IP.Migrations.Seed.InitialDbBuilder.Create() in d:\Freelance Work\Nipun-SPA\SPA\island\Joshi.IP.EntityFramework\Migrations\Seed\InitialDbBuilder.cs:line 22
   at Joshi.IP.Tests.AppTestBase.<.ctor>b__0(IpDbContext context) in d:\Freelance Work\Nipun-SPA\SPA\island\Tests\Joshi.IP.Tests\AppTestBase.cs:line 36
   at Joshi.IP.Tests.AppTestBase.UsingDbContext(Action`1 action) in d:\Freelance Work\Nipun-SPA\SPA\island\Tests\Joshi.IP.Tests\AppTestBase.cs:line 70
   at Joshi.IP.Tests.AppTestBase..ctor() in d:\Freelance Work\Nipun-SPA\SPA\island\Tests\Joshi.IP.Tests\AppTestBase.cs:line 34
   at Joshi.IP.Tests.AcquisitionTypes.AcquisitionTypeAppServiceTests..ctor() in d:\Freelance Work\Nipun-SPA\SPA\island\Tests\Joshi.IP.Tests\AcquisitionTypes\AcquisitionTypeAppServiceTests.cs:line 12
----- Inner Stack Trace -----
   at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
   at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.&lt;Update&gt;b__2(UpdateTranslator ut)
   at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update[T](T noChangesResult, Func`2 updateFunction)
   at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update()
   at System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesToStore>b__35()
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
   at System.Data.Entity.Core.Objects.ObjectContext.&lt;&gt;c__DisplayClass2a.&lt;SaveChangesInternal&gt;b__27()
   at System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options)
   at System.Data.Entity.Internal.InternalContext.SaveChanges()
----- Inner Stack Trace -----
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Effort.Internal.Common.DatabaseReflectionHelper.InsertEntity(ITable table, Object entity, Transaction transaction)
   at Effort.Internal.CommandActions.InsertCommandAction.CreateAndInsertEntity(ITable table, IList`1 memberBindings, Transaction transaction)
   at Effort.Internal.CommandActions.InsertCommandAction.ExecuteDataReader(ActionContext context)
   at Effort.Provider.EffortEntityCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.&lt;Reader&gt;b__c(DbCommand t, DbCommandInterceptionContext`1 c)
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
   at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues)
   at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
----- Inner Stack Trace -----
   at NMemory.Tables.Relation`4.ValidateEntityCore(TForeign foreign)
   at NMemory.Tables.Relation`4.NMemory.Tables.IRelationInternal.ValidateEntity(Object foreign)
   at NMemory.Execution.ExecutionHelper.ValidateForeignKeys(IList`1 relations, IEnumerable`1 referringEntities)
   at NMemory.Execution.CommandExecutor.ExecuteInsert[T](T entity, IExecutionContext context)
   at NMemory.Tables.DefaultTable`2.InsertCore(TEntity entity, Transaction transaction)
   at Effort.Internal.DbManagement.Engine.ExtendedTable`2.InsertCore(TEntity entity, Transaction transaction)
   at NMemory.Tables.Table`2.Insert(TEntity entity, Transaction transaction)
   at Effort.Internal.Common.DatabaseReflectionHelper.WrapperMethods.InsertEntity[TEntity](ITable`1 table, TEntity entity, Transaction transaction)

Hi, Actually those values are there. Really strange.What could be the other reason for this ? Please see the images.

Hi, Actually it worked before the V 1.7 update.Now it's not working.I have changed all the other icons also after the version update. Please see the image below.Thanks.

.AddItem(new MenuItemDefinition(
                    PageNames.App.Tenant.Imports,
                    L("Imports"),
                    url: "tenant.imports",
                    icon: "glyphicon glyphicon-import"
                 )

It's there on the seed data also. Then why's that ? Please see that below. Thanks.

Note : the exception happens here in the below class : _context.SaveChanges();

InitialPropertiesCreator.cs

public class InitialPropertiesCreator
    {
        private readonly IpDbContext _context;

        public InitialPropertiesCreator(IpDbContext context)
        {
            _context = context;
        }

        public void Create()
        {
            var dist1 = _context.Properties.FirstOrDefault(p => p.Dist == "dist1");
            if (dist1 == null)
            {
                _context.Properties.Add(
                    new Property
                    {
                        IsVacant = true,
                        IsPropertyToConsider = false,
                        Dist = "dist1",
                        Sec = "sec1",
                        Blk = "blk1",
                        Lot = "lot1",
                        Lot2 = "lot2",
                        Mls = "mls1",
                        Priority = "priority1",
                        Tfmv = "Tfmv1",
                        Fmv = "Fmv1",
                        Construction = "Construction1",
                        Bid = "Bid1",
                        ListingPrice = 12.25m,
                        Contact = "Contact1",
                        DeedDate = DateTime.UtcNow,
                        TransferTax = 12.9m,
                        OriginalPurchasePrice = 45.6m,
                        Taxes = 85.3m,
                        TotalValuation = 41.2m,
                        Ev = 47.3m,
                        BuyBackAmount = 50.2m,
                        CountyId = 3,
                        PropertyClassId = 1,
                        SchoolDistrictId = 1,
                        StatusId = 1,
                        Address = new Address
                        {
                            StreetName = "1st Street",
                            StreetNumber = "1581",
                            CityId = 1,
                            StateId = 1,
                        },
                        PurchasedById = 1,
                        ShowId = 1,
                        CodeId = 1,

                    });
            }

            var dist2 = _context.Properties.FirstOrDefault(p => p.Dist == "dist2");
            if (dist2 == null)
            {
                _context.Properties.Add(
                    new Property
                    {
                        IsVacant = true,
                        IsPropertyToConsider = false,
                        Dist = "dist2",
                        Sec = "sec2",
                        Blk = "blk2",
                        Lot = "lot2",
                        Lot2 = "lot3",
                        Mls = "mls2",
                        Priority = "priority2",
                        Tfmv = "Tfmv2",
                        Fmv = "Fmv2",
                        Construction = "Construction2",
                        Bid = "Bid2",
                        ListingPrice = 12.25m,
                        Contact = "Contact2",
                        DeedDate = DateTime.UtcNow,
                        TransferTax = 12.9m,
                        OriginalPurchasePrice = 45.6m,
                        Taxes = 85.3m,
                        TotalValuation = 41.2m,
                        Ev = 47.3m,
                        BuyBackAmount = 50.2m,
                        CountyId = 4,
                        PropertyClassId = 2,
                        SchoolDistrictId = 2,
                        StatusId = 2,
                        Address = new Address
                        {
                            StreetName = "2nd Street",
                            StreetNumber = "1582",
                            CityId = 2,
                            StateId = 2,
                        },
                        PurchasedById = 2,
                        ShowId = 2,
                        CodeId = 2,
                    });
            }

            _context.SaveChanges(); // it gives the exception here
        }
    }

InitialCountiesCreator.cs

public class InitialCountiesCreator
    {
        private readonly IpDbContext _context;

        public InitialCountiesCreator(IpDbContext context)
        {
            _context = context;
        }

        public void Create()
        {
            var county1 = _context.Counties.FirstOrDefault(p => p.Name == "Orange");
            if (county1 == null)
            {
                _context.Counties.Add(
                    new County
                    {
                        Name = "Orange",
                        State = "NY",
                    });
            }

            var county2 = _context.Counties.FirstOrDefault(p => p.Name == "Ulster");
            if (county2 == null)
            {
                _context.Counties.Add(
                   new County
                   {
                       Name = "Ulster",
                       State = "NY",
                   });
            }
        }
    }
Showing 11 to 20 of 25 entries