Could you please provide documentation related to RAD tool. What’s it is? What it does? How to use it? How is this useful? Pleas provide some practical examples and sample if possible.
I have added around 100 migrations using Add-Migration in Package Manager Console and run Update-DataBase. Now I want to remove let's say 56th number migration. I have not found any way to do this. EF Core allows me to remove migrations sequences only, which is I think correct. because If I remove an in-between migration, later migration might fail due to dependency on old migrations. But If there is no dependency it should allow me to remove or disable.
I know my question can be invalid, But I'm asking just for the curiosity.
I have posted the same question on SO, please help.
[https://stackoverflow.com/questions/48594103/how-to-call-stored-procedure-with-join-on-multiple-tables-in-entity-framework-co])
Hi, I'm facing problem in getting entity data from DB using Stored Procedure.
I have posted the same question on SO also but didn't get the proper answer, please help.
[https://stackoverflow.com/questions/48565680/how-to-convert-from-dbdatareader-to-taskienumerabletentity-in-entity-framewo])
Hi,
I want to use Some other columns (datatype can be int, long, varchar) as PK or composite PK. But framework supports ID column as autoincrement and PK. This feature is giving me a lot of trouble.
I have posted a lot of queries on SO related to this query, but everyone suggested to use ID as PK. I also tried to make other columns as PK, but it was also giving me lot problems.
Please refer the following posts and please please please help.
[https://stackoverflow.com/questions/46153399/how-to-use-a-varchar-column-other-than-id-column-using-asp-net-boilerplate]) [https://stackoverflow.com/questions/46155968/getting-ambiguous-match-found-exception-while-calling-deleteasync]) [https://stackoverflow.com/questions/46173881/cannot-delete-record-from-table-which-has-identity-column]) [https://stackoverflow.com/questions/46192731/how-to-make-composite-unique-key-in-asp-net-boilerplate])
So my basic requirement is to Have a ID auto increment column Have a primary key column or a composite primary key Have some unique constraint columns I should not face the above mentioned issues.
Could you please some tips, tricks, shortcuts or utilities , automationwhile working with abp framework which can help in speed up development or testing speed.
I want to create some user-defined functions using code first approach in abp framework.
I have created stored procedures xyz by adding xyz.sql inside EntityFrameworkCore\Migrations\Stored Procedures folder, But not able to find a way to create a function, please help.
I have implemented a service which has some get, post, update and delete methods.
I want to make this service restful.
Here is my service code.
public class TestAppService : MyProjectAppServiceBase, ITestAppService
{
public async Task CreateTest(TestDetailsDto input)
{
}
public PagedResultDto<FetchTestDetails> GetSearchTest(FetchTestDetails searchInput)
{
}
public TestDetailsDto GetTestDetailsForEdit(EntityDto input)
{
}
public async Task UpdateTest(TestDetailsDto input)
{
}
public async Task DeleteTest(EntityDto input)
{
}
public ListResultDto<FetchTestDetails> GetAllCurrencies()
{
}
}
so instead of >http://localhost:22742/api/services/app/Test/GetTestDetailsForEdit?Id=1 url should be something like >http://localhost:22742/api/services/app/Currency?Id=1 for get api.
for >http://localhost:22742/api/services/app/Test/CreateTest it should be something like >http://localhost:22742/api/services/app/Test for post api.
for> <a class="postlink" href="http://localhost:22742/api/services/app/Test/DeleteTest?Id=1">http://localhost:22742/api/services/app ... eTest?Id=1</a> it should be >http://localhost:22742/api/services/app/Test?Id=1
public MyEntityInput GetMyEntityDetailsforEditRepo(EntityDto input)
{
var MyEntityDetails = ObjectMapper.Map<MyEntityInput>(Get(input.Id));
var MyChildEntity = from tjs in _myChildMyEntityAssociationRepository.GetAll()
join tj in _myChildEntityRepository.GetAll() on tjs.MyChildEntityId equals tj.Id
where tjs.MyEntityId == input.Id
select new MyChildEntityDetailsDto
{
Id = tj.Id,
MyChildEntityCode = tj.MyChildEntityCode,
MyChildEntityDesc = tj.MyChildEntityDesc,
MyChildEntityName = tj.MyChildEntityName
};
MyEntityDetails.MyChildEntity = ObjectMapper.Map<List<MyChildEntityDetailsDto>>(MyChildEntity);
return MyEntityDetails;
}
Getting the below exception, while calling the above method.
INFO 2017-12-22 09:08:26,189 [25 ] pNetCore.Cors.Infrastructure.CorsService - Policy execution successful. INFO 2017-12-22 09:08:26,227 [22 ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method MyCompany.MyProject.Business.Services.MyEntitys.MyEntityAppService.GetMyEntityDetailsforEdit (MyCompany.MyProject.Business.Services) with arguments (Abp.Application.Services.Dto.EntityDto) - ModelState is Valid INFO 2017-12-22 09:08:28,835 [25 ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method MyCompany.MyProject.Business.Services.Common.CommonAppService.GetLookupItems (MyCompany.MyProject.Business.Services) with arguments (MyCompany.MyProject.Business.Dto.Common.GetLookupInput) - ModelState is Valid INFO 2017-12-22 09:09:16,443 [25 ] etCore.Mvc.Internal.ObjectResultExecutor - Executing ObjectResult, writing value Microsoft.AspNetCore.Mvc.ControllerContext. INFO 2017-12-22 09:09:16,449 [25 ] ore.Mvc.Internal.ControllerActionInvoker - Executed action MyCompany.MyProject.Business.Services.Common.CommonAppService.GetLookupItems (MyCompany.MyProject.Business.Services) in 50348.6255ms INFO 2017-12-22 09:09:16,477 [25 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 50385.6354ms 200 application/json; charset=utf-8 ERROR 2017-12-22 09:09:16,480 [22 ] Mvc.ExceptionHandling.AbpExceptionFilter - There is already an open DataReader associated with this Command which must be closed first. System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first. at System.Data.SqlClient.SqlInternalConMyCompanytionTds.ValidateConMyCompanytionForExecute(SqlCommand command) at System.Data.SqlClient.SqlInternalTransaction.Rollback() at System.Data.SqlClient.SqlTransaction.Dispose(Boolean disposing) at System.Data.Common.DbTransaction.Dispose() at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.Dispose() at Abp.EntityFrameworkCore.Uow.DbContextEfCoreTransactionStrategy.Dispose(IIocResolver iocResolver) in D:\Github\aspnetboilerplate\src\Abp.EntityFrameworkCore\EntityFrameworkCore\Uow\DbContextEfCoreTransactionStrategy.cs:line 84 at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.DisposeUow() in D:\Github\aspnetboilerplate\src\Abp.EntityFrameworkCore\EntityFrameworkCore\Uow\EfCoreUnitOfWork.cs:line 143 at Abp.Domain.Uow.UnitOfWorkBase.Dispose() in D:\Github\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkBase.cs:line 296 at Abp.AspNetCore.Mvc.Uow.AbpUowActionFilter.<OnActionExecutionAsync>d__4.MoveNext() in D:\Github\aspnetboilerplate\src\Abp.AspNetCore\AspNetCore\Mvc\Uow\AbpUowActionFilter.cs:line 51 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextExceptionFilterAsync>d__23.MoveNext() INFO 2017-12-22 09:09:16,503 [22 ] etCore.Mvc.Internal.ObjectResultExecutor - Executing ObjectResult, writing value Microsoft.AspNetCore.Mvc.ControllerContext. INFO 2017-12-22 09:09:16,516 [22 ] ore.Mvc.Internal.ControllerActionInvoker - Executed action MyCompany.MyProject.Business.Services.MyEntitys.MyEntityAppService.GetMyEntityDetailsforEdit (MyCompany.MyProject.Business.Services) in 50358.9931ms INFO 2017-12-22 09:09:16,559 [22 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 50467.3493ms 500 application/json; charset=utf-8
I have a requirement that I have to read/use two appsettings.json file, but it's not working.
Please find my code below.
using System;
using Abp.AutoMapper;
using Abp.Configuration.Startup;
using Abp.Dependency;
using Abp.Domain.Repositories;
using Abp.Modules;
using Abp.Net.Mail;
using Abp.TestBase;
using Abp.Zero.Configuration;
using Castle.MicroKernel.Registration;
using MyCompany.MyProject.Articles;
using MyCompany.MyProject.Business.DAL;
using MyCompany.MyProject.Business.Dto.Articles;
using MyCompany.MyProject.Business.Dto.Classifications;
using MyCompany.MyProject.Business.Dto.Common;
using MyCompany.MyProject.Business.Dto.Currency;
using MyCompany.MyProject.Business.Dto.Deposit;
using MyCompany.MyProject.Business.Dto.PromoPack;
using MyCompany.MyProject.Business.Dto.Property;
using MyCompany.MyProject.Business.Dto.Suppliers;
using MyCompany.MyProject.Business.Dto.Taxes;
using MyCompany.MyProject.Business.Dto.TenderTypes;
using MyCompany.MyProject.Business.Model.Articles;
using MyCompany.MyProject.Business.Model.Common;
using MyCompany.MyProject.Business.Model.Stores;
using MyCompany.MyProject.Business.Model.Suppliers;
using MyCompany.MyProject.Business.Model.Taxes;
using MyCompany.MyProject.Business.Repositories.Interfaces;
using MyCompany.MyProject.Business.Repositories.Repositories;
using MyCompany.MyProject.Common;
using MyCompany.MyProject.EntityFrameworkCore;
using MyCompany.MyProject.PromoPack;
using MyCompany.MyProject.Security.Recaptcha;
using MyCompany.MyProject.Tests.DependencyInjection;
using MyCompany.MyProject.Tests.Url;
using MyCompany.MyProject.Tests.Web;
using MyCompany.MyProject.Url;
using NSubstitute;
using MyCompany.MyProject.Business.Dto.Stores;
using MyCompany.MyProject.Business.Services.Articles;
using MyCompany.MyProject.Configuration;
using MyCompany.MyProject.Processors.Core;
using Abp.AspNetZeroCore;
using Microsoft.Extensions.Configuration;
using System.IO;
namespace MyCompany.MyProject.Tests
{
[DependsOn(
typeof(MyProjectServicesModule),
typeof(MyProjectEntityFrameworkCoreModule),
typeof(MyProjectRepositoryModule),
typeof(AbpTestBaseModule))]
public class MyProjectTestModule : AbpModule
{
public MyProjectTestModule(MyProjectEntityFrameworkCoreModule abpZeroTemplateEntityFrameworkCoreModule)
{
abpZeroTemplateEntityFrameworkCoreModule.SkipDbContextRegistration = true;
}
public override void PreInitialize()
{
var configuration = GetConfiguration();
Configuration.UnitOfWork.Timeout = TimeSpan.FromMinutes(30);
Configuration.UnitOfWork.IsTransactional = false;
//Disable static mapper usage since it breaks unit tests (see https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2052)
Configuration.Modules.AbpAutoMapper().UseStaticMapper = false;
//Use database for language management
Configuration.Modules.Zero().LanguageManagement.EnableDbLocalization();
RegisterFakeService<AbpZeroDbMigrator>();
IocManager.Register<IAppUrlService, FakeAppUrlService>();
IocManager.Register<IWebUrlService, FakeWebUrlService>();
IocManager.Register<IRecaptchaValidator, FakeRecaptchaValidator>();
IocManager.Register<IJobLeaseManager, BlobStorageJobLeaseManager>();
IocManager.Register<IJobQueueManager, JobQueueManager>();
Configuration.ReplaceService<IAppConfigurationAccessor, TestAppConfigurationAccessor>();
Configuration.ReplaceService<IEmailSender, NullEmailSender>(DependencyLifeStyle.Transient);
Configuration.Modules.AspNetZero().LicenseCode = configuration["AbpZeroLicenseCode"];
}
public override void Initialize()
{
ServiceCollectionRegistrar.Register(IocManager);
}
private void RegisterFakeService<TService>()
where TService : class
{
IocManager.IocContainer.Register(
Component.For<TService>()
.UsingFactoryMethod(() => Substitute.For<TService>())
.LifestyleSingleton()
);
}
private static IConfigurationRoot GetConfiguration()
{
return AppConfigurations.Get(Directory.GetCurrentDirectory(), addUserSecrets: true);
}
}
}
I have overwritten the TestAppConfigurationAccessor file like this.
using Abp.Dependency;
using Microsoft.Extensions.Configuration;
using MyCompany.MyProject.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace MyCompany.MyProject.Tests
{
public class TestAppConfigurationAccessor : IAppConfigurationAccessor, ISingletonDependency
{
public IConfigurationRoot Configuration { get; }
public TestAppConfigurationAccessor()
{
Configuration = BuildConfig();
}
private IConfigurationRoot BuildConfig()
{
var currentPath = Directory.GetCurrentDirectory();
var config = new ConfigurationBuilder()
.AddJsonFile(Path.Combine(currentPath, "..", "..", "..", "..", "..", "src", "MyCompany.MyProject.Web.Host", $"appsettings.json"), false);
config.AddJsonFile(Path.Combine(currentPath, $"testingappsettings.json"), false);
return config.Build();
}
}
}
AppConfigurations file:
using System.Collections.Concurrent;
using Abp.Extensions;
using Abp.Reflection.Extensions;
using Microsoft.Extensions.Configuration;
namespace MyCompany.MyProject.Configuration
{
public static class AppConfigurations
{
private static readonly ConcurrentDictionary<string, IConfigurationRoot> ConfigurationCache;
static AppConfigurations()
{
ConfigurationCache = new ConcurrentDictionary<string, IConfigurationRoot>();
}
public static IConfigurationRoot Get(string path, string environmentName = null, bool addUserSecrets = false)
{
var cacheKey = path + "#" + environmentName + "#" + addUserSecrets;
return ConfigurationCache.GetOrAdd(
cacheKey,
_ => BuildConfiguration(path, environmentName, addUserSecrets)
);
}
private static IConfigurationRoot BuildConfiguration(string path, string environmentName = null, bool addUserSecrets = false)
{
var builder = new ConfigurationBuilder()
.SetBasePath(path)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
if (!environmentName.IsNullOrWhiteSpace())
{
builder = builder.AddJsonFile($"appsettings.{environmentName}.json", optional: true);
}
builder = builder.AddEnvironmentVariables();
if (addUserSecrets)
{
builder.AddUserSecrets(typeof(AppConfigurations).GetAssembly());
}
return builder.Build();
}
}
}
testingappsettings.json:
{
"MasterDataFiles": {
"TestingEntity1": {
"UseStaging": "true"
},
"TestingEntity2": {
"UseStaging": "false"
}
}
}
appsettings.json:
{
"AbpZeroLicenseCode": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
Please let me know if its possible with only one json.
I tried to copy the contents of one json to another, but my test cases are failing and I'm not able to debug tests.