OpenRiaServices.Server.EntityFrameworkCore 3.1.0

Prefix Reserved
dotnet add package OpenRiaServices.Server.EntityFrameworkCore --version 3.1.0                
NuGet\Install-Package OpenRiaServices.Server.EntityFrameworkCore -Version 3.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenRiaServices.Server.EntityFrameworkCore" Version="3.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenRiaServices.Server.EntityFrameworkCore --version 3.1.0                
#r "nuget: OpenRiaServices.Server.EntityFrameworkCore, 3.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OpenRiaServices.Server.EntityFrameworkCore as a Cake Addin
#addin nuget:?package=OpenRiaServices.Server.EntityFrameworkCore&version=3.1.0

// Install OpenRiaServices.Server.EntityFrameworkCore as a Cake Tool
#tool nuget:?package=OpenRiaServices.Server.EntityFrameworkCore&version=3.1.0                

Stand With Ukraine

TERM OF USE

By using this project or its source code, for any purpose and in any shape or form, you grant your agreement to all the following statements:

  • You condemn Russia and its military aggression against Ukraine
  • You recognize that Russia is an occupant that unlawfully invaded a sovereign state
  • You support Ukraine's territorial integrity, including its claims over temporarily occupied territories of Crimea and Donbas
  • You do not support the Russian invasion or contribute to its propaganda'

This excludes usage by the Russian state, Russian state-owned companies, Russian education who spread propaganda instead of truth, anyone who work with the filtration camps, or finance the war by importing Russian oil or gas.

  • You allow anonymized telemetry to collected and sent during the preview releases to gather feedback about usage

Getting Started

  1. Ensure you have setup and configured OpenRiaServices.Hosting.AspNetCore
  2. Add a reference to OpenRiaServices.Server.EntityFrameworkCore dotnet add package OpenRiaServices.Server.EntityFrameworkCore
  3. Add one or more domainservices. Given that you have a Ef Core model named MyDbContext with an entity MyEntity you add CRUD methods using something similar to below
using using Microsoft.EntityFrameworkCore;
using OpenRiaServices.Server.EntityFrameworkCore;

[EnableClientAccess]
public class MyDomainService : DbDomainService<MyDbContext>
{
    // Not required: But it is generally a good idea to allow dependency injection of DbContext
    public MyDomainService(MyDbContext dbContext)
        : base(context)
    { }

    /* Example of CUD methods */
    public void InsertMyEntity(MyEntity entity)
        => DbContext.Entry(entity).State = EntityState.Added; // Or  DbContext.Add, but it might add related entities differently

    public void UpdateMyEntity(MyEntity entity)
        => base.AttachAsModified(entity); // This sets state to Modified and set modified status on individual properties based on client changes and if `RountTripOriginal` attribute is specified or not

    public void DeleteMyEntity(MyEntity entity)
        => DbContext.Entry(entity).State =  EntityState.Deleted;

    /* Query: 
    * Return IQueryable<> to automatically allow the client to add filtering, paging etc. 
    * The queries are performed async for best performance
    */
    [Query]
    IQueryable<MyEntity> GetMyEntities()
        => DbContext.MyEntities.OrderBy(x => x.Id); // Sort by id to get stable Skip/Take if client does paging
}
  1. Ensure that MyDomainService is mapped, (See Setup instructions in OpenRiaServices.Hosting.AspNetCore readme)

Owned Entities

  • one-to-one relations using Owned Entities are fully supported
    • Any EF Core configuration/metadata applied to the owned entity (such as Required, MaxLength etc) are part of generated client Code
  • one-to-many relations might work, but it has not been verified at the moment

Owned Entities without explicit key

EF Core owned entities are mapped to OpenRiaServices's Complex Types as long as the owned entity does not have have an explicit key.

Owned Entities with explicit key

If an explicit key to an owned entity then they are mapped as a normal entity and the navigation property to the owned entity adds [Composition]

This makes the owned entity available during Insert, Update and Delete operations and prevents if from accidentaly having all fields set to null.

Complex Types

The Complex Types introduced in EF Core 8 are partially supported* with some limitations.

  1. The types are mapped to to OpenRiaServices's Complex Types
  2. Any ef core configuration/metadata applied to the ComplexType (as part of fluent configuration) IS NOT discovered. The DbDomainServiceDescriptionProvider and DbDomainService classes does not have any special handling of Complex Types.
    • Attributes on the types are discovered as expected using the normal built in reflection based attribute discovery
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.0 193 6/13/2024
3.0.0 179 4/14/2024
2.0.2 502 5/26/2023
2.0.2-preview.2 93 8/1/2023
2.0.2-ci.9 63 3/14/2024
2.0.1 226 4/14/2023
2.0.1-tags-v-5-3-0.8 89 4/14/2023
2.0.0 369 11/25/2022
1.0.0 398 6/7/2022