Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "manojreddy"

I am trying to create a model that has a Customer entity with two references to Address entities: BillingAddress and ShippingAddress.

Customer

public class Customer
{
    public Guid CustomerId {  get;set;}

    public Guid? BillingAddressId { get; set; }
    public Address BillingAddress { get; set; }

    public Guid? ShippingAddressId { get; set; }
    public Address ShippingAddress { get; set; }
}

Address

public class Address
{
    public Guid AddressId { get; set; }

    public Customer Customer { get; set; }
    public Guid CustomerId { get; set; }
}

OnModelCreating

modelBuilder.Entity<Address>(eb =>
{
    eb.HasOne(e => e.Customer).WithOne(o => o.BillingAddress).OnDelete(DeleteBehavior.Cascade);
});

modelBuilder.Entity<Address>(eb =>
{
    eb.HasOne(e => e.Customer).WithOne(o => o.ShippingAddress).OnDelete(DeleteBehavior.Cascade);
});

I get the following error when trying to create the migration:

Can not]Cannot create a relationship between 'Customer.ShippingAddress' and 'Address.Customer', because there already is a relationship between 'Customer.BillingAddress' and 'Address.Customer'. Navigation properties can only participate in a single relationship.[/quote]

I'm trying to configure the model so that when the Customer is deleted the referenced Addresses are deleted as well. I would like to be able to do this without loading the Addresses into the Context and relying on the database to cascade.

I'm planning to start a new project, I have downloaded 5.3.0. Is there any major change coming very soon? if yes then I will hold for some time and start with the upcoming version else I will start from 5.3.0.

Please provide your feedback.

I have an existing database on SQL server, But I don't have the model classes or the backend C# code(only the database which has tables, SPs, and triggers). I want to build a Web application on top of this already existing database using aspnetzero framework, means I want to use the already existing database also and start my web application using this database. I want to use the existing database tables, SPs, and triggers also.

Is there any way to generate the migration, dbcontext, and snapshot of this already existing database, so that If need to add/modify the existing tables/SPs/Triggers, I can create using the code first approach.

So could you please let me know what could be the best approach to proceed with this kind of requirement?

I am using ASP.Net boilerplate framework + SQL Server 2016 in my project. Recently I have faced a challenge with migration from SQL Server to MongoDB. I have found that it is possible with ASP .NET boilerplate and installed required NuGet packages, however, due to the lack of documentation the only thing I have managed to do is to define respective RepositoryBase class:

public abstract class MyRepositoryBase<TEntity, TPrimaryKey> : MongoDbRepositoryBase<TEntity, TPrimaryKey>
    where TEntity : class, IEntity<TPrimaryKey>
{
    protected MyRepositoryBase(IMongoDatabaseProvider databaseProvider)
        : base(databaseProvider)
    {

    }

}

As far as I understand, first of all, I need to define connection string somewhere now. And then populate the database with required basic data(which previously had been done by EF Core migrations). Obviously, EF Core in the new approach is obsolete so does that mean for my DbContext class that it is obsolete as well? Actually, there are plenty of questions in relation to ASP .NET boilerplate and MongoDB integration, therefore my current post is actually a request for provision of some kind of example of the existing integration. Thank you in advance.

With this framework being predominantly a Microsoft framework I was wondering if in the future it would be worth while building a template for Razor Web Pages?

Not looked into it too much myself but I would imagine there would be some effort involved to take the current Abp Controller logic into some sort of a Abp Page base class.

Just asking for peoples personal opinion - no right or wrong here :-)

I have some model classes.

public class AClass : FullAuditedEntity<int>
{

}

and one interface like below.

public interface ISomeInterface<T, TEntity> where T : BaseFileEntity where TEntity : class, IEntity<int>
{

}

Now If I add one extra model class like below.

public class BClass : FullAuditedEntity<string>
{

}

I have to define another interface for this change like below.

public interface ISomeInterface<T, TEntity> where T : BaseFileEntity where TEntity : class, IEntity<string>
{

}

So basically it's duplicate code. Is there any better way to do this?

I'm just wondering how SQLite in test cases know about the SQL Server database?

I have one entity which has a column as int in Branch A. Now I switch to a different BranchB. There I create a migration and change column to varchar and runUpdate-Database. Now If I switch to Branch A again. If I see in the code the column datatype isint, but in the database, its datatype is varchar. But I want its datatype to be int. I can not even remove this migration from BranchA because it was created in Branch B.I can see only one way to solve this issue is to delete the database and run Update-Database, But I will lose all data by doing this. Is there any better way to solve this issue.

I have tried to create PK to a different column other than the default Id column with the help of [this](<a class="postlink" href="https://stackoverflow.com/questions/46153399/how-to-use-a-varchar-column-other-than-id-for-pk/48604164#48604164">https://stackoverflow.com/questions/461 ... 4#48604164</a>) solution. Its working fine for every scenario, but my test cases are failing. I have created TestId as PK,Id as autoincrement identity.

It's failing when I'm running test case to create the record and giving the following exception.

SQLite Error 19: 'NOT NULL constraint failed: Test.Id'.

Testcase:

public async Task Should_Create_Test_With_Valid_Arguments()
{
    var Test = await CreateNewTest(K_TESTCode1);
    Test.Code = await _TestAppService.CreateTest(Test);

    UsingDbContext((System.Action<EntityFrameworkCore.MyProjectDbContext>)(context =>
    {
        context.Test.FirstOrDefault(
            u => u.Code == Test.Code
        ).ShouldNotBeNull();
    }));
}

CreateNewTest Method

public async Task<TestDetailsDto> CreateNewTest(string Code)
{
    return CreateTestEntity(Code);
}

public TestDetailsDto CreateTestEntity(string Code)
{
    var Test = new TestDetailsDto
    {
        Code = Code,
    };
    return Test;
}

CreateTest Method

public async Task<string> CreateTest(TestDetailsDto input)
{
    try
    {
        int TestId = await InsertAndGetIdAsync(ObjectMapper.Map<Test>(input));
        return input.Code;
    }
    catch (Exception ex)
    {
        throw new UserFriendlyException(ex.Message);
    }
}

StackTrace

Starting: MyCompany.MyProject.Tests [3/6/2018 5:49:05 AM Error] [xUnit.net 00:00:26.6288060] MyCompany.MyProject.Tests.Classifications.TestAppService_Test.Should_Create_Classification_With_Valid_Arguments [FAIL] [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6308959] Microsoft.EntityFrameworkCore.DbUpdateException : An error occurred while updating the entries. See the inner exception for details. [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6309648] ---- Microsoft.Data.Sqlite.SqliteException : SQLite Error 19: 'NOT NULL constraint failed: Test.Id'. [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6323228] Stack Trace: [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6335736] at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.<ExecuteAsync>d__32.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6336454] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6336945] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6337390] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6337813] at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.<ExecuteAsync>d__10.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6338186] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6338566] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6338982] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6339344] at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6339755] at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.<SaveChangesAsync>d__61.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6340070] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6340441] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6340850] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6341236] at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6341641] at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.<SaveChangesAsync>d__59.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6341947] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6342311] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6342694] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6343065] at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6343431] at Microsoft.EntityFrameworkCore.DbContext.<SaveChangesAsync>d__48.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6343752] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6344115] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6344511] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6345061] D:\Github\aspnetboilerplate\src\Abp.EntityFrameworkCore\EntityFrameworkCore\AbpDbContext.cs(215,0): at Abp.EntityFrameworkCore.AbpDbContext.<SaveChangesAsync>d__49.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6348796] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6349402] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6349858] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6350373] D:\Github\aspnetboilerplate\src\Abp.EntityFrameworkCore\EntityFrameworkCore\Uow\EfCoreUnitOfWork.cs(163,0): at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.<SaveChangesInDbContextAsync>d__20.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6350804] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6351201] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6351665] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6352134] D:\Github\aspnetboilerplate\src\Abp.EntityFrameworkCore\EntityFrameworkCore\Uow\EfCoreUnitOfWork.cs(68,0): at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.<SaveChangesAsync>d__12.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6352535] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6352935] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6353330] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6353808] D:\Github\aspnetboilerplate\src\Abp.EntityFrameworkCore\EntityFrameworkCore\Uow\EfCoreUnitOfWork.cs(83,0): at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.<CompleteUowAsync>d__14.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6354207] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6354685] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6355115] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6355558] D:\Github\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkBase.cs(276,0): at Abp.Domain.Uow.UnitOfWorkBase.<CompleteAsync>d__57.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6355921] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6356306] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6356695] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6357135] D:\Github\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs(90,0): at Abp.Domain.Uow.UnitOfWorkInterceptor.<>c__DisplayClass6_0.<<PerformAsyncUow>b__0>d.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6357587] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6359838] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6360322] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6360807] D:\Github\aspnetboilerplate\src\Abp\Threading\InternalAsyncHelper.cs(40,0): at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinally>d__1.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6361199] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6361583] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6362001] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6362425] D:\Github\aspnetboilerplate\src\Abp\Threading\InternalAsyncHelper.cs(20,0): at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithFinally>d__0.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6362869] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6363327] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6363782] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6364332] C:\Users\pooja.dhadse\Source\MyProject\aspnet-core\test\MyCompany.MyProject.Tests\Classifications\TestAppService_Test.cs(20,0): at MyCompany.MyProject.Tests.Classifications.TestAppService_Test.<Should_Create_Classification_With_Valid_Arguments>d__1.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6364752] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6365185] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6365609] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6365946] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6366305] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6366710] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6367020] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6367403] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6367790] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6368122] ----- Inner Stack Trace ----- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6368492] at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6368883] at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6369347] at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6369741] at Microsoft.Data.Sqlite.SqliteCommand.<ExecuteDbDataReaderAsync>d__52.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6370066] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6370420] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6370829] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6371183] at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6371579] at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.<ExecuteAsync>d__17.MoveNext() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6371886] --- End of stack trace from previous location where exception was thrown --- [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6372250] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6372632] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6372995] at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() [3/6/2018 5:49:06 AM Informational] [xUnit.net 00:00:26.6373387] at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.

Code:

public class Test: FullAuditedEntity
{
    // PK
    [MaxLength(NVarcharLength14), DataType(DataType.Text)]
    public virtual string Code { get; set; }

    // Unique constraint
    public int MyUniqueId { get; set; }
}

public class AbpProjectNameDbContext : AbpZeroDbContext&lt;Tenant, Role, User, AbpProjectNameDbContext&gt;
{
    /* Define a DbSet for each entity of the application */    
    public DbSet&lt;Test&gt; Tests { get; set; }

    public AbpProjectNameDbContext(DbContextOptions&lt;AbpProjectNameDbContext&gt; options) : base(options) {}

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        modelBuilder.Entity&lt;Test&gt;().Property(t => t.Id).ValueGeneratedOnAdd(); // Auto-increment
        modelBuilder.Entity&lt;Test&gt;().HasAlternateKey(t => t.Id);                // Auto-increment, closed-wont-fix: https://github.com/aspnet/EntityFrameworkCore/issues/7380
        modelBuilder.Entity&lt;Test&gt;().HasKey(t => t.Code);                       // PK
        modelBuilder.Entity&lt;Test&gt;().HasIndex(t => t.MyUniqueId).IsUnique();    // Unique constraint
    }
}

Generated migration:

protected override void Up(MigrationBuilder migrationBuilder)
{
    migrationBuilder.CreateTable(
        name: "Tests",
        columns: table => new
        {
            Code = table.Column&lt;string&gt;(nullable: false),
            Id = table.Column&lt;int&gt;(nullable: false)
                .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
            MyUniqueId = table.Column&lt;int&gt;(nullable: false)
        },
        constraints: table =>
        {
            table.PrimaryKey("PK_Tests", x => x.Code);
        });

    migrationBuilder.CreateIndex(
        name: "IX_Tests_MyUniqueId",
        table: "Tests",
        column: "MyUniqueId",
        unique: true);
}

Usage:

public async Task MyMethod()
{
    await _repository.InsertAndGetIdAsync(new Test
    {
        Code = "One",
        MyUniqueId = 1
    });

    // Valid
    await _repository.InsertAndGetIdAsync(new Test
    {
        Code = "Two",
        MyUniqueId = 2
    });

    try
    {
        await _repository.InsertAndGetIdAsync(new Test
        {
            Code = "One", // PK conflict
            MyUniqueId = 3
        });
    }
    catch (Exception e)
    {
    }

    try
    {
        await _repository.InsertAndGetIdAsync(new Test
        {
            Code = "Three",
            MyUniqueId = 1 // Unique constraint conflict
        });
    }
    catch (Exception e)
    {
        throw;
    }

    return null;
}

I have a suggestion for you guys, please let me know if it's feasible or a valid case?

I have a table with ID column as PK, this ID is being referred as a foreign key (onDelete: ReferentialAction.Cascade) in some other tables. So When I delete the entity it should make entries for all the related tables also.

select * from AbpEntityChanges

select * from AbpEntityChangeSets

select * from AbpEntityPropertyChanges

Above queries give records only for the main table.

Showing 11 to 20 of 68 entries