OData / RESTier

A turn-key library for building RESTful services
http://odata.github.io/RESTier
Other
471 stars 136 forks source link

can pulblic method '' #758

Open mbossX opened 4 months ago

mbossX commented 4 months ago

file src/Microsoft.Restier.EntityFramework.Shared/Extensions/RestierEntityFrameworkServiceCollectionExtensions.cs

method AddEFProviderServices

can public this method?

robertmclaws commented 4 months ago

Hello. It's not meant to be called publicly, you're supposed to use one of the other public methods. Can I ask why you need it to be public?

Thanks!

mbossX commented 4 months ago

Currently, we need a DbContext and define some DbSet ,like this:

public partial class DatabaseContext : DbContext
{
    public DbSet<User> Users { get; set; }
    public DbSet<Role> Roles { get; set; }

    public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options){}
}

I want to define DbContext dynamic with Attribute on Model class,like this:

[MyDbSet]
[Table("user")]
public class User
{
    [Key]
    [Column("id")]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public required long id { get; set; }
    [Required]
    [Column("name")]
    public required string name { get; set; }
}

but now, AddEFCoreProviderServices<DatabaseContext> can not do this. if AddEFProviderServices is public, I can pass my dynamic DbContext instance to this method.

i am a beginner in c#, I would be very grateful if you could show me other ways to do this.