Giter Site home page Giter Site logo

orleans.entityframeworkcore's Introduction

Summary

!! DO NOT USE IN PRODUCTION. THIS CODE IS EXPERIMENTAL !!

This package provides various experimental Microsoft Orleans providers backed by Entity Framework Core.

Using Entity Framework Core as the backing store for various Microsoft Orleans providers allows us to utilize any supported EF provider to back Orleans functionality (theoretically).

Compatability

Should be compatable with Orleans 2.x

Installation

Install from https://www.nuget.org/packages/Orleans.EntityFrameworkCore/

Supported Orleans Providers

  • IMembershipTable (used for orleans silo clustering rendezvous)
  • IGatewayListProvider (used for client clustering rendezvous)
  • IStorageProvider (used for grain state storage for any named provider)
  • IReminderTable (used for grain reminders)

Entity Framework Database Providers

Theoretically all entity framework core database providers listed here should work.

This project explicitly tests the following providers and major database versions:

  • Microsoft.EntityFrameworkCore.InMemory
  • Microsoft.EntityFrameworkCore.Sqlite
  • Microsoft.EntityFrameworkCore.SqlServer
    • SqlServer 2017 CU12
  • MySql.Data.EntityFrameworkCore
    • MariaDB v05.5.63
    • MariaDB v10.4.2
    • Mysql v5.7.25
    • Mysql v8.0.15
  • Npgsql.EntityFrameworkCore.PostgreSQL
    • CockroachDB v2.1.4
    • Postgres v9.6.11
    • Postgres v10.6.0
    • Postgres v11.1.0
  • Pomelo.EntityFrameworkCore.MySql
    • MariaDB v05.5.63
    • MariaDB v10.4.2
    • Mysql v5.7.25
    • Mysql v8.0.15

See the src/Orleans.EntityFrameworkCore.Tests project for more details. Database versions are based on latest available docker images from Docker Hub and go back 3 major versions when availble.

If you have used Orleans.EntityFrameworkCore successfully with a provider or database not listed here, please open an issue and report your experience!

Configuration Sample

Silo

new SiloHostBuilder()
    .AddEntityFrameworkStorage() // "Default" orleans storage provider
    .AddEntityFrameworkStorage("PubSub") // add storage for PubSub (streams)
    .AddEntityFrameworkStorage("MyCustomProvider") // your own custom storage provider name
    .Configure<ClusterOptions>(options =>
    {
        // make sure to configure cluster information
        options.ClusterId = <cluster_id>;
        options.ServiceId = <service_id>;
    })
    .ConfigureServices(services =>
    {
        // add the OrleansEFContext to the silo services.
        // be sure to configure this context with any EF provider
        // specific options (pgsql, sql server, in-memory etc)
        services.AddDbContext<OrleansEFContext>();
    })
    .UseEntityFrameworkClustering() // silo clustering
    .UseEntityFrameworkReminders() // silo reminders
    .Build();

Client

new ClientBuilder()
    .ConfigureServices(services =>
    {
        // add the OrleansEFContext to the silo services.
        // be sure to configure this context with any EF provider
        // specific options (pgsql, sql server, in-memory etc)
        services.AddDbContext<OrleansEFContext>();
    })
    .UseEntityFrameworkClustering() // client clustering
    .Build();

Migrations

This project provides EF Core migrations for EF providers that support migrations.

You can invoke migrations by obtaining a instance of the OrleansEFContext and calling AutoMigrate

using (var scope = silo.Services.CreateScope())
{
    var context = scope.ServiceProvider.GetService(typeof(OrleansEFContext)) as OrleansEFContext;
    await context.AutoMigrate();
}

License

This project is licensed under the terms of the MIT license

orleans.entityframeworkcore's People

Contributors

smizdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

orleans.entityframeworkcore's Issues

Reminder Grain etag mismatch when calling RegisterOrUpdateReminder

when calling a reminder register or update:

public override async Task OnActivateAsync()
        {
            await RegisterOrUpdateReminder(
                nameof(SomeFunc),
                TimeSpan.FromMinutes(1),
                TimeSpan.FromMinutes(1)
            );

            await base.OnActivateAsync();
        }

orleans runtime in client integration throws:

fail: Orleans.EntityFrameworkCore.OrleansEFReminderTable[0]
      UpsertRow
Orleans.EntityFrameworkCore.OrleansEFReminderException+EtagMismatch: etag mismatch. grainId: GrainReference=0000000000000000000000000000000003ffffffaa8c2775 reminderName: ScheduleNow
   at Orleans.EntityFrameworkCore.OrleansEFReminderGrain.UpsertRow(ReminderEntry entry)
   at Orleans.EntityFrameworkCore.OrleansCodeGenOrleansEFReminderGrainMethodInvoker.Invoke(IAddressable grain, InvokeMethodRequest request)
   at Orleans.Runtime.GrainMethodInvoker.Invoke() in D:\build\agent\_work\24\s\src\Orleans.Runtime\Core\GrainMethodInvoker.cs:line 91
   at Orleans.Runtime.InsideRuntimeClient.Invoke(IAddressable target, IInvokable invokable, Message message) in D:\build\agent\_work\24\s\src\Orleans.Runtime\Core\InsideRuntimeClient.cs:line 351
   at Orleans.OrleansTaskExtentions.<ToTypedTask>g__ConvertAsync|4_0[T](Task`1 asyncTask) in D:\build\agent\_work\24\s\src\Orleans.Core\Async\TaskExtensions.cs:line 100
   at Orleans.EntityFrameworkCore.OrleansEFReminderTable.UpsertRow(ReminderEntry entry)
fail: Orleans.LifecycleSubject[100450]
      Lifecycle start canceled due to errors at stage 2000

Orleans.EntityFrameworkCore includes reminders in its test suite, not sure why we are getting this failure when integrated into another application.

Needs Review

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.