diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d98da485..bee7bb743 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ Represents the **NuGet** versions. +## v5.18.1 +- *Fixed:* Upgraded `CoreEx` to include all related fixes and improvements; possible related updates that may be required are: + - The Entity Framework (EF) `AddEfDb` previously registered the `T` as the `IEfDB` (shorthand for `AddEfDb`); this has been corrected to register the `T` as the `T` only. Therefore, the registering should be updated to be more explcit, or the `IEfDb` dependency references should use the explicit `T` where required. + - The Cosmos DB configuration must now be on the container and not the database; any lazy-loading references of the container can be removed as these are now cached internally. + ## v5.18.0 - *Enhancement:* Added `net9.0` support. - *Enhancement:* Deprecated `net7.0` support; no longer supported by [Microsoft](https://dotnet.microsoft.com/en-us/platform/support/policy). diff --git a/Common.targets b/Common.targets index 9a2cf6901..6222350ac 100644 --- a/Common.targets +++ b/Common.targets @@ -1,6 +1,6 @@ - 5.18.0 + 5.18.1 preview Avanade Avanade diff --git a/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj b/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj index 607621a83..f8282bbb7 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj @@ -5,8 +5,8 @@ true - - + + diff --git a/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj b/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj index 70a647fd4..b8d7760b8 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj @@ -12,8 +12,8 @@ - - - + + + \ No newline at end of file diff --git a/samples/Cdr.Banking/Cdr.Banking.Business/Data/AccountData.cs b/samples/Cdr.Banking/Cdr.Banking.Business/Data/AccountData.cs index 652af717d..be19010a6 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Business/Data/AccountData.cs +++ b/samples/Cdr.Banking/Cdr.Banking.Business/Data/AccountData.cs @@ -5,7 +5,7 @@ namespace Cdr.Banking.Business.Data; public partial class AccountData { - private static QueryArgsConfig _config = QueryArgsConfig.Create() + private static readonly QueryArgsConfig _config = QueryArgsConfig.Create() .WithFilter(filter => filter .AddReferenceDataField(nameof(Model.Account.OpenStatus), c => c.WithValue(os => os == OpenStatus.All ? throw new FormatException("Value not valid for filtering.") : os)) .AddReferenceDataField(nameof(Model.Account.ProductCategory)) @@ -49,7 +49,7 @@ partial void AccountDataCtor() private Task> GetBalanceOnImplementationAsync(string? accountId) { // Use the 'Account' model and select for the specified id to access the balance property. - return Result.GoAsync(_cosmos.Accounts.ModelContainer.Query(q => q.Where(x => x.Id == accountId)).SelectFirstOrDefaultWithResultAsync()) + return Result.GoAsync(_cosmos.Accounts.Model.Query(q => q.Where(x => x.Id == accountId)).SelectFirstOrDefaultWithResultAsync()) .WhenAs(a => a is not null, a => { var bal = _cosmos.Mapper.Map(a!.Balance); diff --git a/samples/Cdr.Banking/Cdr.Banking.Business/Data/CosmosDb.cs b/samples/Cdr.Banking/Cdr.Banking.Business/Data/CosmosDb.cs index eb898c288..b5faaf9d3 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Business/Data/CosmosDb.cs +++ b/samples/Cdr.Banking/Cdr.Banking.Business/Data/CosmosDb.cs @@ -26,37 +26,28 @@ public interface ICosmos : ICosmosDb /// public class CosmosDb : CoreEx.Cosmos.CosmosDb, ICosmos { - private readonly Lazy> _accounts; - private readonly Lazy> _accountDetails; - private readonly Lazy> _transactions; - /// /// Initializes a new instance of the class. /// public CosmosDb(Mac.Database database, IMapper mapper, CosmosDbInvoker? invoker = null) : base(database, mapper, invoker) { - // Apply an authorization filter to all operations to ensure only the valid data is available based on the users context; i.e. only allow access to Accounts within list defined on ExecutionContext. - UseAuthorizeFilter("Account", (q) => ((IQueryable)q).Where(x => ExecutionContext.Current.Accounts.Contains(x.Id!))); - UseAuthorizeFilter("Transaction", (q) => ((IQueryable)q).Where(x => ExecutionContext.Current.Accounts.Contains(x.AccountId!))); - - // Lazy create the containers. - _accounts = new(() => Container("Account")); - _accountDetails = new(() => Container("Account")); - _transactions = new(() => Container("Transaction")); + // Apply the authorization filter to all containers to ensure only the valid data is available based on the users context; i.e.only allow access to Accounts within list defined on ExecutionContext. + Container("Account").UseAuthorizeFilter(q => q.Where(x => ExecutionContext.Current.Accounts.Contains(x.Id!))); + Container("Transaction").UseAuthorizeFilter(q => q.Where(x => ExecutionContext.Current.Accounts.Contains(x.AccountId!))); } /// /// Exposes entity from Account container. /// - public CosmosDbContainer Accounts => _accounts.Value; + public CosmosDbContainer Accounts => Container("Account"); /// /// Exposes entity from Account container. /// - public CosmosDbContainer AccountDetails => _accountDetails.Value; + public CosmosDbContainer AccountDetails => Container("Account"); /// /// Exposes entity from Account container. /// - public CosmosDbContainer Transactions => _transactions.Value; + public CosmosDbContainer Transactions => Container("Transaction"); } \ No newline at end of file diff --git a/samples/Cdr.Banking/Cdr.Banking.Business/Validation/TransactionArgsValidator.cs b/samples/Cdr.Banking/Cdr.Banking.Business/Validation/TransactionArgsValidator.cs index 02dc1526a..bc920a467 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Business/Validation/TransactionArgsValidator.cs +++ b/samples/Cdr.Banking/Cdr.Banking.Business/Validation/TransactionArgsValidator.cs @@ -12,7 +12,7 @@ public TransactionArgsValidator() { // Default FromDate where not provided, as 90 days less than ToDate; where no ToDate then assume today (now). Make sure FromDate is not greater than ToDate. Property(x => x.FromDate) - .Default(a => (a.ToDate!.HasValue ? a.ToDate.Value : CoreEx.ExecutionContext.SystemTime.UtcNow).AddDays(-90)) + .Default(a => (a.ToDate!.HasValue ? a.ToDate.Value : SystemTime.Timestamp).AddDays(-90)) .CompareProperty(CompareOperator.LessThanEqual, y => y.ToDate).DependsOn(y => y.ToDate); // Make sure MinAmount is not greater than MaxAmount. diff --git a/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj b/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj index 608f11434..168aaba31 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj @@ -10,6 +10,6 @@ - + \ No newline at end of file diff --git a/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj b/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj index c0fdd93ae..ac0adde47 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj @@ -34,13 +34,13 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/samples/Cdr.Banking/Cdr.Banking.Test/FixtureSetup.cs b/samples/Cdr.Banking/Cdr.Banking.Test/FixtureSetup.cs index fae54a696..e69627da2 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Test/FixtureSetup.cs +++ b/samples/Cdr.Banking/Cdr.Banking.Test/FixtureSetup.cs @@ -33,13 +33,13 @@ public void OneTimeSetUp() var ac = await _cosmosDb.Database.ReplaceOrCreateContainerAsync(new Cosmos.ContainerProperties { - Id = _cosmosDb.Accounts.Container.Id, + Id = _cosmosDb.Accounts.CosmosContainer.Id, PartitionKeyPath = "/_partitionKey" }, cancellationToken: ct).ConfigureAwait(false); var tc = await _cosmosDb.Database.ReplaceOrCreateContainerAsync(new Cosmos.ContainerProperties { - Id = _cosmosDb.Transactions.Container.Id, + Id = _cosmosDb.Transactions.CosmosContainer.Id, PartitionKeyPath = "/accountId" }, cancellationToken: ct).ConfigureAwait(false); diff --git a/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj b/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj index 706632824..947885dc5 100644 --- a/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj +++ b/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj @@ -12,9 +12,9 @@ - - - + + + diff --git a/samples/Demo/Beef.Demo.Api/Startup.cs b/samples/Demo/Beef.Demo.Api/Startup.cs index 040e1fc93..739cb7f0f 100644 --- a/samples/Demo/Beef.Demo.Api/Startup.cs +++ b/samples/Demo/Beef.Demo.Api/Startup.cs @@ -1,5 +1,6 @@ using Beef.Demo.Common.Agents; using CoreEx.Database; +using CoreEx.EntityFrameworkCore; using CoreEx.Events; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; @@ -54,7 +55,7 @@ public void ConfigureServices(IServiceCollection services) // .AddSingleton(_ => new TripOData(new Uri(WebApiStartup.GetConnectionString(_config, "TripOData")))); services.AddDatabase(sp => new Database(() => new SqlConnection(sp.GetRequiredService().DatabaseConnectionString), sp.GetRequiredService>())) .AddDbContext() - .AddEfDb(); + .AddEfDb(); services.AddSingleton(sp => { diff --git a/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj b/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj index e2e56850c..0ac0fb707 100644 --- a/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj +++ b/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj @@ -16,14 +16,14 @@ - - - - - - - - + + + + + + + + diff --git a/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj b/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj index a24738b22..8ffae0610 100644 --- a/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj +++ b/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj @@ -9,8 +9,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj b/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj index 4fda69262..ba5a5c566 100644 --- a/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj +++ b/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj @@ -52,9 +52,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj b/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj index 95abdd2db..4e29eb770 100644 --- a/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj +++ b/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj @@ -5,9 +5,9 @@ true - - - + + + diff --git a/samples/My.Hr/My.Hr.Business/Data/Generated/EmployeeData.cs b/samples/My.Hr/My.Hr.Business/Data/Generated/EmployeeData.cs index df9189ad4..248b0975f 100644 --- a/samples/My.Hr/My.Hr.Business/Data/Generated/EmployeeData.cs +++ b/samples/My.Hr/My.Hr.Business/Data/Generated/EmployeeData.cs @@ -10,7 +10,7 @@ namespace My.Hr.Business.Data; public partial class EmployeeData : IEmployeeData { private readonly IDatabase _db; - private readonly IEfDb _ef; + private readonly HrEfDb _ef; private readonly IEventPublisher _events; private Func, EmployeeArgs?, IQueryable>? _getByArgsOnQuery; @@ -18,9 +18,9 @@ public partial class EmployeeData : IEmployeeData /// Initializes a new instance of the class. /// /// The . - /// The . + /// The . /// The . - public EmployeeData(IDatabase db, IEfDb ef, IEventPublisher events) + public EmployeeData(IDatabase db, HrEfDb ef, IEventPublisher events) { _db = db.ThrowIfNull(); _ef = ef.ThrowIfNull(); _events = events.ThrowIfNull(); EmployeeDataCtor(); } partial void EmployeeDataCtor(); // Enables additional functionality to be added to the constructor. diff --git a/samples/My.Hr/My.Hr.Business/Data/Generated/PerformanceReviewData.cs b/samples/My.Hr/My.Hr.Business/Data/Generated/PerformanceReviewData.cs index 7d398aeb9..fc3f036e4 100644 --- a/samples/My.Hr/My.Hr.Business/Data/Generated/PerformanceReviewData.cs +++ b/samples/My.Hr/My.Hr.Business/Data/Generated/PerformanceReviewData.cs @@ -9,16 +9,16 @@ namespace My.Hr.Business.Data; /// public partial class PerformanceReviewData : IPerformanceReviewData { - private readonly IEfDb _ef; + private readonly HrEfDb _ef; private readonly IEventPublisher _events; private Func, Guid, IQueryable>? _getByEmployeeIdOnQuery; /// /// Initializes a new instance of the class. /// - /// The . + /// The . /// The . - public PerformanceReviewData(IEfDb ef, IEventPublisher events) + public PerformanceReviewData(HrEfDb ef, IEventPublisher events) { _ef = ef.ThrowIfNull(); _events = events.ThrowIfNull(); PerformanceReviewDataCtor(); } partial void PerformanceReviewDataCtor(); // Enables additional functionality to be added to the constructor. diff --git a/samples/My.Hr/My.Hr.Business/Data/Generated/ReferenceDataData.cs b/samples/My.Hr/My.Hr.Business/Data/Generated/ReferenceDataData.cs index bde52065d..ce569cdc4 100644 --- a/samples/My.Hr/My.Hr.Business/Data/Generated/ReferenceDataData.cs +++ b/samples/My.Hr/My.Hr.Business/Data/Generated/ReferenceDataData.cs @@ -9,13 +9,13 @@ namespace My.Hr.Business.Data; /// public partial class ReferenceDataData : IReferenceDataData { - private readonly IEfDb _ef; + private readonly HrEfDb _ef; /// /// Initializes a new instance of the class. /// - /// The . - public ReferenceDataData(IEfDb ef) + /// The . + public ReferenceDataData(HrEfDb ef) { _ef = ef.ThrowIfNull(); ReferenceDataDataCtor(); } partial void ReferenceDataDataCtor(); // Enables additional functionality to be added to the constructor. diff --git a/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj b/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj index fabe9840f..08abd1f2d 100644 --- a/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj +++ b/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj @@ -6,10 +6,10 @@ latest - - - - + + + + \ No newline at end of file diff --git a/samples/My.Hr/My.Hr.CodeGen/entity.beef-5.yaml b/samples/My.Hr/My.Hr.CodeGen/entity.beef-5.yaml index 6339c021f..b7e0327cb 100644 --- a/samples/My.Hr/My.Hr.CodeGen/entity.beef-5.yaml +++ b/samples/My.Hr/My.Hr.CodeGen/entity.beef-5.yaml @@ -19,6 +19,7 @@ eventSourceKind: Relative eventTransaction: true eventPublish: Data databaseSchema: Hr +entityFrameworkType: HrEfDb entities: # Creating an Employee base with only the subset of fields that we want returned from the GetByArgs. # - As we will be returning more than one we need the Collection and CollectionResult. diff --git a/samples/My.Hr/My.Hr.CodeGen/refdata.beef-5.yaml b/samples/My.Hr/My.Hr.CodeGen/refdata.beef-5.yaml index d1249902a..84489f999 100644 --- a/samples/My.Hr/My.Hr.CodeGen/refdata.beef-5.yaml +++ b/samples/My.Hr/My.Hr.CodeGen/refdata.beef-5.yaml @@ -1,5 +1,6 @@ webapiRoutePrefix: ref refDataType: Guid +entityFrameworkType: HrEfDb entities: - { name: Gender, webApiRoutePrefix: genders, autoImplement: EntityFramework, entityFrameworkModel: EfModel.Gender } - { name: TerminationReason, webApiRoutePrefix: terminationReasons, autoImplement: EntityFramework, entityFrameworkModel: EfModel.TerminationReason } diff --git a/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj b/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj index 57b3fe3df..4b12ec6bc 100644 --- a/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj +++ b/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj @@ -6,6 +6,6 @@ true - + \ No newline at end of file diff --git a/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj b/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj index a8a9a01d9..73cfb210e 100644 --- a/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj +++ b/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj @@ -32,18 +32,18 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj b/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj index 839804634..a95530056 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj @@ -6,12 +6,12 @@ True - - + + - + diff --git a/samples/MyEf.Hr/MyEf.Hr.Api/appsettings.json b/samples/MyEf.Hr/MyEf.Hr.Api/appsettings.json index c32164e10..ab6c1b016 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Api/appsettings.json +++ b/samples/MyEf.Hr/MyEf.Hr.Api/appsettings.json @@ -12,9 +12,11 @@ "ServiceBusSender": { "QueueOrTopicName": "event-stream" }, - "EventOutboxHostedService": { - "MaxDequeueSize": "10", - "Interval": "00:00:10" - }, - "IncludeExceptionInResult": true + "CoreEx": { + "EventOutboxHostedService": { + "MaxDequeueSize": "10", + "Interval": "00:00:10" + }, + "IncludeExceptionInResult": true + } } \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Business/Data/Generated/EmployeeData.cs b/samples/MyEf.Hr/MyEf.Hr.Business/Data/Generated/EmployeeData.cs index c13062b88..2034c5865 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Business/Data/Generated/EmployeeData.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Business/Data/Generated/EmployeeData.cs @@ -9,15 +9,15 @@ namespace MyEf.Hr.Business.Data; /// public partial class EmployeeData : IEmployeeData { - private readonly IEfDb _ef; + private readonly HrEfDb _ef; private Func, EmployeeArgs?, IQueryable>? _getByArgsOnQuery; private Func, QueryArgs?, IQueryable>? _getByQueryOnQuery; /// /// Initializes a new instance of the class. /// - /// The . - public EmployeeData(IEfDb ef) + /// The . + public EmployeeData(HrEfDb ef) { _ef = ef.ThrowIfNull(); EmployeeDataCtor(); } partial void EmployeeDataCtor(); // Enables additional functionality to be added to the constructor. diff --git a/samples/MyEf.Hr/MyEf.Hr.Business/Data/Generated/PerformanceReviewData.cs b/samples/MyEf.Hr/MyEf.Hr.Business/Data/Generated/PerformanceReviewData.cs index 17df94d65..79b6ee1ac 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Business/Data/Generated/PerformanceReviewData.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Business/Data/Generated/PerformanceReviewData.cs @@ -9,14 +9,14 @@ namespace MyEf.Hr.Business.Data; /// public partial class PerformanceReviewData : IPerformanceReviewData { - private readonly IEfDb _ef; + private readonly HrEfDb _ef; private Func, Guid, IQueryable>? _getByEmployeeIdOnQuery; /// /// Initializes a new instance of the class. /// - /// The . - public PerformanceReviewData(IEfDb ef) + /// The . + public PerformanceReviewData(HrEfDb ef) { _ef = ef.ThrowIfNull(); PerformanceReviewDataCtor(); } partial void PerformanceReviewDataCtor(); // Enables additional functionality to be added to the constructor. diff --git a/samples/MyEf.Hr/MyEf.Hr.Business/Data/Generated/ReferenceDataData.cs b/samples/MyEf.Hr/MyEf.Hr.Business/Data/Generated/ReferenceDataData.cs index ac56747d4..54d4a3a09 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Business/Data/Generated/ReferenceDataData.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Business/Data/Generated/ReferenceDataData.cs @@ -9,13 +9,13 @@ namespace MyEf.Hr.Business.Data; /// public partial class ReferenceDataData : IReferenceDataData { - private readonly IEfDb _ef; + private readonly HrEfDb _ef; /// /// Initializes a new instance of the class. /// - /// The . - public ReferenceDataData(IEfDb ef) + /// The . + public ReferenceDataData(HrEfDb ef) { _ef = ef.ThrowIfNull(); ReferenceDataDataCtor(); } partial void ReferenceDataDataCtor(); // Enables additional functionality to be added to the constructor. diff --git a/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj b/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj index 850c916c3..c0b75141c 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj @@ -6,11 +6,11 @@ latest - - - - - + + + + + diff --git a/samples/MyEf.Hr/MyEf.Hr.CodeGen/entity.beef-5.yaml b/samples/MyEf.Hr/MyEf.Hr.CodeGen/entity.beef-5.yaml index 47a803b07..4284aaf17 100644 --- a/samples/MyEf.Hr/MyEf.Hr.CodeGen/entity.beef-5.yaml +++ b/samples/MyEf.Hr/MyEf.Hr.CodeGen/entity.beef-5.yaml @@ -17,6 +17,7 @@ eventSourceKind: Relative eventActionFormat: PastTense eventTransaction: true autoImplement: EntityFramework +entityFrameworkType: HrEfDb entities: # Creating an Employee base with only the subset of fields that we want returned from the GetByArgs. # - As we will be returning more than one we need the Collection and CollectionResult. diff --git a/samples/MyEf.Hr/MyEf.Hr.CodeGen/refdata.beef-5.yaml b/samples/MyEf.Hr/MyEf.Hr.CodeGen/refdata.beef-5.yaml index b26b7eda8..fb1fb2faf 100644 --- a/samples/MyEf.Hr/MyEf.Hr.CodeGen/refdata.beef-5.yaml +++ b/samples/MyEf.Hr/MyEf.Hr.CodeGen/refdata.beef-5.yaml @@ -1,6 +1,7 @@ webApiRoutePrefix: ref refDataType: Guid autoImplement: EntityFramework +entityFrameworkType: HrEfDb entities: - { name: Gender, entityFrameworkModel: EfModel.Gender } - { name: TerminationReason, entityFrameworkModel: EfModel.TerminationReason } diff --git a/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj b/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj index acc2eb229..c8ee391ac 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj @@ -7,6 +7,6 @@ true - + \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj b/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj index 0fe6cb6e4..5ed9cbaa7 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj @@ -15,10 +15,10 @@ - - + + - + diff --git a/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj b/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj index bfa87ff80..4a586ed57 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj @@ -17,19 +17,19 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + diff --git a/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj b/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj index 4efab00b8..d7362bb9f 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj @@ -32,18 +32,18 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/templates/Beef.Template.Solution/content/.template.config/template.json b/templates/Beef.Template.Solution/content/.template.config/template.json index 23a720f80..7df51074a 100644 --- a/templates/Beef.Template.Solution/content/.template.config/template.json +++ b/templates/Beef.Template.Solution/content/.template.config/template.json @@ -85,7 +85,7 @@ "type": "generated", "generator": "constant", "parameters": { - "value": "3.30.0" + "value": "3.31.0" }, "replaces": "CoreExVersion" }, @@ -93,7 +93,7 @@ "type": "generated", "generator": "constant", "parameters": { - "value": "5.18.0" + "value": "5.18.1" }, "replaces": "BeefVersion" }, @@ -101,7 +101,7 @@ "type": "generated", "generator": "constant", "parameters": { - "value": "5.0.0" + "value": "5.3.0" }, "replaces": "UnitTestExVersion" }, diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Api/Company.AppName.Api.csproj b/templates/Beef.Template.Solution/content/Company.AppName.Api/Company.AppName.Api.csproj index b1fdc31eb..fc614440c 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.Api/Company.AppName.Api.csproj +++ b/templates/Beef.Template.Solution/content/Company.AppName.Api/Company.AppName.Api.csproj @@ -13,7 +13,7 @@ - + diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Api/Startup.cs b/templates/Beef.Template.Solution/content/Company.AppName.Api/Startup.cs index bcc87dd40..ef9d3291a 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.Api/Startup.cs +++ b/templates/Beef.Template.Solution/content/Company.AppName.Api/Startup.cs @@ -122,7 +122,7 @@ public void ConfigureServices(IServiceCollection services) #endif // Add Azure monitor open telemetry. - services.AddOpenTelemetry().UseAzureMonitor().WithTracing(b => b.AddSource("CoreEx.*", "Company.AppName.*", "Microsoft.EntityFrameworkCore.*", "EntityFrameworkCore.*")); + //services.AddOpenTelemetry().UseAzureMonitor().WithTracing(b => b.AddSource("CoreEx.*", "Company.AppName.*", "Microsoft.EntityFrameworkCore.*", "EntityFrameworkCore.*")); // Add the swagger capabilities. services.AddSwaggerGen(options => diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Api/appsettings.json b/templates/Beef.Template.Solution/content/Company.AppName.Api/appsettings.json index d08dc386e..c0211d602 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.Api/appsettings.json +++ b/templates/Beef.Template.Solution/content/Company.AppName.Api/appsettings.json @@ -41,24 +41,26 @@ //#if (implement_httpagent) "XxxAgentUrl": "https://backend/", //#endif - //#if (implement_services) - "ServiceBusSender": { - "QueueOrTopicName": "event-stream" - }, - "EventOutboxHostedService": { - "MaxDequeueSize": "10", - "Interval": "00:01:00" - }, - //#endif - "Invokers": { - "Default": { - "TracingEnabled": true, - "LoggingEnabled": true + "CoreEx": { + //#if (implement_services) + "ServiceBusSender": { + "QueueOrTopicName": "event-stream" }, - "CoreEx.Validation.ValidationInvoker": { - "TracingEnabled": false, - "LoggingEnabled": false - } - }, - "IncludeExceptionInResult": true + "EventOutboxHostedService": { + "MaxDequeueSize": "10", + "Interval": "00:01:00" + }, + //#endif + "Invokers": { + "Default": { + "TracingEnabled": true, + "LoggingEnabled": true + }, + "CoreEx.Validation.ValidationInvoker": { + "TracingEnabled": false, + "LoggingEnabled": false + } + }, + "IncludeExceptionInResult": true + } } \ No newline at end of file diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Business/Company.AppName.Business.csproj b/templates/Beef.Template.Solution/content/Company.AppName.Business/Company.AppName.Business.csproj index b4a2e8a04..f9f56aafd 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.Business/Company.AppName.Business.csproj +++ b/templates/Beef.Template.Solution/content/Company.AppName.Business/Company.AppName.Business.csproj @@ -24,13 +24,13 @@ - + - + \ No newline at end of file diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Business/Data/AppNameCosmosDb.cs b/templates/Beef.Template.Solution/content/Company.AppName.Business/Data/AppNameCosmosDb.cs index d244a0ed8..2e22195d2 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.Business/Data/AppNameCosmosDb.cs +++ b/templates/Beef.Template.Solution/content/Company.AppName.Business/Data/AppNameCosmosDb.cs @@ -14,20 +14,15 @@ public class AppNameCosmosDb : CosmosDb /// public const string PersonContainerId = "Person"; - private readonly Lazy> _persons; - /// /// Initializes a new instance of the class. /// /// The CosmosDb . /// The . - public AppNameCosmosDb(Database database, IMapper mapper) : base(database, mapper) - { - _persons = new(() => Container(PersonContainerId)); - } + public AppNameCosmosDb(Database database, IMapper? mapper = null) : base(database, mapper) { } /// /// Exposes entity from the container. /// - public CosmosDbContainer Persons => _persons.Value; + public CosmosDbContainer Persons => Container(PersonContainerId); } \ No newline at end of file diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Business/Data/AppNameEfDb.cs b/templates/Beef.Template.Solution/content/Company.AppName.Business/Data/AppNameEfDb.cs index dc6a0b247..c2d782595 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.Business/Data/AppNameEfDb.cs +++ b/templates/Beef.Template.Solution/content/Company.AppName.Business/Data/AppNameEfDb.cs @@ -5,4 +5,4 @@ /// /// The entity framework database context. /// The . -public class AppNameEfDb(AppNameEfDbContext dbContext, IMapper mapper) : EfDb(dbContext, mapper) { } \ No newline at end of file +public class AppNameEfDb(AppNameEfDbContext dbContext, IMapper? mapper = null) : EfDb(dbContext, mapper) { } \ No newline at end of file diff --git a/templates/Beef.Template.Solution/content/Company.AppName.CodeGen/entity.beef-5.yaml b/templates/Beef.Template.Solution/content/Company.AppName.CodeGen/entity.beef-5.yaml index f8d7718b9..20c871e66 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.CodeGen/entity.beef-5.yaml +++ b/templates/Beef.Template.Solution/content/Company.AppName.CodeGen/entity.beef-5.yaml @@ -42,6 +42,7 @@ eventSourceRoot: Company/AppName eventSourceKind: Relative webApiAutoLocation: true autoImplement: EntityFramework +entityFrameworkType: AppNameEfDb //#if (implement_mysql) etagDefaultMapperConverter: EncodedStringToDateTimeConverter //#endif @@ -84,13 +85,13 @@ entities: } //#endif //#if (implement_cosmos) -cosmosType: AppNameCosmosDb eventSubjectRoot: Company eventActionFormat: PastTense eventSourceRoot: Company/AppName eventSourceKind: Relative webApiAutoLocation: true autoImplement: Cosmos +cosmosType: AppNameCosmosDb refDataText: true entities: # The following is an example Entity with CRUD and Query operations defined accessing a Cosmos DB. diff --git a/templates/Beef.Template.Solution/content/Company.AppName.CodeGen/refdata.beef-5.yaml b/templates/Beef.Template.Solution/content/Company.AppName.CodeGen/refdata.beef-5.yaml index faeccd1af..067efabf5 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.CodeGen/refdata.beef-5.yaml +++ b/templates/Beef.Template.Solution/content/Company.AppName.CodeGen/refdata.beef-5.yaml @@ -10,6 +10,7 @@ entities: //#if (implement_sqlserver) refDataType: Guid autoImplement: EntityFramework +entityFrameworkType: AppNameEfDb entities: # The following is an example read-only reference data Entity accessing a SQL Database using EntityFramework. - { name: Gender, entityFrameworkModel: EfModel.Gender } @@ -17,6 +18,7 @@ entities: //#if (implement_mysql) refDataType: int autoImplement: EntityFramework +entityFrameworkType: AppNameEfDb etagDefaultMapperConverter: EncodedStringToDateTimeConverter entities: # The following is an example read-only reference data Entity accessing a SQL Database using EntityFramework. @@ -25,15 +27,16 @@ entities: //#if (implement_postgres) refDataType: int autoImplement: EntityFramework +entityFrameworkType: AppNameEfDb etagDefaultMapperConverter: EncodedStringToUInt32Converter entities: # The following is an example read-only reference data Entity accessing a SQL Database using EntityFramework. - { name: Gender, entityFrameworkModel: EfModel.Gender } //#endif //#if (implement_cosmos) -cosmosName: AppNameCosmosDb refDataType: Guid autoImplement: Cosmos +cosmosType: AppNameCosmosDb entities: # The following is an example read-only reference data Entity accessing Cosmos DB. - { name: Gender, cosmosContainerId: RefData, cosmosValueContainer: true, cosmosModel: Model.Gender, dataModel: true } diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Services/appsettings.json b/templates/Beef.Template.Solution/content/Company.AppName.Services/appsettings.json index 183ee6f48..20dca5341 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.Services/appsettings.json +++ b/templates/Beef.Template.Solution/content/Company.AppName.Services/appsettings.json @@ -29,16 +29,19 @@ // Set using environment variables: 'AppName_CosmosDb__ConnectionString' and 'AppName_CosmosDb__DatabaseId' (keeps values out of config file). "CosmosConnectionString": "AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==;AccountEndpoint=https://localhost:8081", "CosmosDatabaseId": "Company.AppName", - //#endif //#if (implement_httpagent) + //#endif + //#if (implement_httpagent) "XxxAgentUrl": "https://backend/", //#endif - "ServiceBusOrchestratedSubscriber": { - "AbandonOnTransient": true, - "RetryDelay": "00:00:05" - }, - "Invokers": { - "Default": { - "TracingEnabled": true + "CoreEx": { + "ServiceBusOrchestratedSubscriber": { + "AbandonOnTransient": true, + "RetryDelay": "00:00:05" + }, + "Invokers": { + "Default": { + "TracingEnabled": true + } } } } \ No newline at end of file diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Test/Apis/FixtureSetup.cs b/templates/Beef.Template.Solution/content/Company.AppName.Test/Apis/FixtureSetup.cs index 45efba000..89cf566a6 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.Test/Apis/FixtureSetup.cs +++ b/templates/Beef.Template.Solution/content/Company.AppName.Test/Apis/FixtureSetup.cs @@ -47,7 +47,7 @@ public void OneTimeSetUp() await cosmosDb.Database.Client.CreateDatabaseIfNotExistsAsync(cosmosDb.Database.Id, cancellationToken: ct).ConfigureAwait(false); // Create 'Person' container. - var cdp = cosmosDb.Database.DefineContainer(cosmosDb.Persons.Container.Id, "/_partitionKey") + var cdp = cosmosDb.Database.DefineContainer(cosmosDb.Persons.CosmosContainer.Id, "/_partitionKey") .WithIndexingPolicy() .WithCompositeIndex() .Path("/lastName", AzCosmos.CompositePathSortOrder.Ascending) diff --git a/tests/Beef.Template.Solution.UnitTest/Beef.Template.Solution.UnitTest.csproj b/tests/Beef.Template.Solution.UnitTest/Beef.Template.Solution.UnitTest.csproj index 95fd9f25c..ab6b96fcc 100644 --- a/tests/Beef.Template.Solution.UnitTest/Beef.Template.Solution.UnitTest.csproj +++ b/tests/Beef.Template.Solution.UnitTest/Beef.Template.Solution.UnitTest.csproj @@ -6,7 +6,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tools/Beef.CodeGen.Core/Beef.CodeGen.Core.csproj b/tools/Beef.CodeGen.Core/Beef.CodeGen.Core.csproj index 5108935d8..1619c3c72 100644 --- a/tools/Beef.CodeGen.Core/Beef.CodeGen.Core.csproj +++ b/tools/Beef.CodeGen.Core/Beef.CodeGen.Core.csproj @@ -33,8 +33,8 @@ - - + + diff --git a/tools/Beef.Database.Core/Beef.Database.Core.csproj b/tools/Beef.Database.Core/Beef.Database.Core.csproj index a57a96312..19e4fc18d 100644 --- a/tools/Beef.Database.Core/Beef.Database.Core.csproj +++ b/tools/Beef.Database.Core/Beef.Database.Core.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/tools/Beef.Database.MySql/Beef.Database.MySql.csproj b/tools/Beef.Database.MySql/Beef.Database.MySql.csproj index 6dcdc79fd..83b6b4b8c 100644 --- a/tools/Beef.Database.MySql/Beef.Database.MySql.csproj +++ b/tools/Beef.Database.MySql/Beef.Database.MySql.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/tools/Beef.Database.Postgres/Beef.Database.Postgres.csproj b/tools/Beef.Database.Postgres/Beef.Database.Postgres.csproj index 2a6de314f..63d31746b 100644 --- a/tools/Beef.Database.Postgres/Beef.Database.Postgres.csproj +++ b/tools/Beef.Database.Postgres/Beef.Database.Postgres.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj b/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj index e3985c344..ad457835d 100644 --- a/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj +++ b/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj b/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj index 62265d516..66fe446cc 100644 --- a/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj +++ b/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj @@ -8,8 +8,8 @@ - - + +