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

can pulblic method '' #758

Open
mbossX opened this issue May 23, 2024 · 2 comments
Open

can pulblic method '' #758

mbossX opened this issue May 23, 2024 · 2 comments

Comments

@mbossX
Copy link

mbossX commented May 23, 2024

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

method AddEFProviderServices

can public this method?

@robertmclaws
Copy link
Collaborator

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
Copy link
Author

mbossX commented May 24, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants