Skip to content

EF Converters in Separate Project #676

@ardalis

Description

@ardalis

Describe the feature

I'm trying to generate a VO for a Name in my Core project which has no references to EF Core. However, the generated code has errors at compile time, saying
image

This issue is that I don't have EF Core referenced from this project, nor do I want to do so. That is only referenced from my Infrastructure project, which is also where my DbContext and all of my EF configuration classes are.

Is there a way to generate the converters in the Infrastructure project rather than in the VO itself?

My Value Object (in Core project)

[ValueObject<string>(conversions: Conversions.EfCoreValueConverter | Conversions.SystemTextJson)]
public partial class ProjectName
{
  private static Validation Validate(in string name) => String.IsNullOrEmpty(name) ? 
    Validation.Invalid("Name cannot be empty") : 
    Validation.Ok;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions