Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with configuration for dotnet core web api #661

Closed
ADringer opened this issue Jul 2, 2019 · 5 comments
Closed

Issue with configuration for dotnet core web api #661

ADringer opened this issue Jul 2, 2019 · 5 comments
Labels

Comments

@ADringer
Copy link

ADringer commented Jul 2, 2019

Hi,

I'm having an issue running EventFlow with the latest version in dotnet core web api. I have the following setup:

services.AddEventFlow(options =>
                options
                    .AddAspNetCore(o => o.AddDefaultMetadataProviders())
                    .AddDefaults(typeof(AgencyCreatedEvent).Assembly)
                    .AddDefaults(typeof(Startup).Assembly)
                .ConfigureMsSql(MsSqlConfiguration.New
                    .SetConnectionString(@"Server=(localdb)\mssqllocaldb;Database=EventFlowDb;User Id=eventFlow;Password=Password!"))
                .UseMssqlEventStore()
                .ConfigureEntityFramework(EntityFrameworkConfiguration.New)
                .AddDbContextProvider<AgencyContext, MsSqlDbContextProvider>()
                .UseEntityFrameworkReadModel<AgencyReadModel, AgencyContext>()
                .UseEntityFrameworkReadModel<ManagementServiceReadModel, AgencyContext>()
                .CreateResolver());

But is coming up with the error:

No versioned type definition for 'AgencyCreatedEvent' with version 1 in 'EventDefinitionService'

I have added the following attribute to the event:

 [EventVersion("AgencyCreated", 1)]
    public class AgencyCreatedEvent : IAggregateEvent<Agency, AgencyId>
    { }

But still get the same issue. With this latest version I can not run EventFlow at all.

@frankebersoll
Copy link
Contributor

Please try calling RunBootstrapperOnHostStartup in AddAspNetCore. Seems I need to change the design and make this opt-out instead of opt-in...

@ADringer
Copy link
Author

ADringer commented Jul 2, 2019

@frankebersoll Still get the same error. My startup now looks like:

services.AddEventFlow(options =>
                options
                    .AddAspNetCore(o => o.RunBootstrapperOnHostStartup().AddDefaultMetadataProviders())                  
                    .AddDefaults(typeof(AgencyCreatedEvent).Assembly)
                    .AddDefaults(typeof(Startup).Assembly)
                .ConfigureMsSql(MsSqlConfiguration.New
                    .SetConnectionString(@"Server=(localdb)\mssqllocaldb;Database=EventFlowDb;User Id=eventFlow;Password=Password!"))
                .UseMssqlEventStore()
                .ConfigureEntityFramework(EntityFrameworkConfiguration.New)
                .AddDbContextProvider<AgencyContext, MsSqlDbContextProvider>()
                .UseEntityFrameworkReadModel<AgencyReadModel, AgencyContext>()
                .UseEntityFrameworkReadModel<ManagementServiceReadModel, AgencyContext>()
                .CreateResolver());

@ADringer
Copy link
Author

ADringer commented Jul 3, 2019

Found the issue. Originally I hadn't set any EventVersion attributes on my events. I then updated to the latest nuget package and started getting that error.

After purging the database (I'm only doing a POC) and started saving events it started working. It looks like the latest version expects events to have the EventVersion attribute?

@rasmus rasmus added bug and removed question labels Jun 11, 2021
@rasmus
Copy link
Member

rasmus commented Jun 11, 2021

Need to investigate this

@rasmus
Copy link
Member

rasmus commented Mar 4, 2022

Work on event naming is scheduled in #907, closing this as the original issue was found and there's already an issue for the event naming

@rasmus rasmus closed this as completed Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants