I want pass my entities to my SQL Server database from API in .Net Core. I need an extension or module that can be added to Container builder and Helps me to use in ConfigureServices method in Startup.cs I found a project according to my needs (https://github.com/devmentors/DNC-DShop), but this sample has been implemented with MongoDB. I want to implement the same thing with SQLSERVER DB and EF ORM.
This code is inside startup file For Mongo Sample :
builder.AddMongo();
builder.AddMongoRepository<Cart>("Carts");
builder.AddMongoRepository<Customer>("Customers");
builder.AddMongoRepository<Product>("Products");
This code in applicationsetting.json file:
"mongo": {
"connectionString": "mongodb://localhost:27017",
"database": "customers-service",
"seed": false
},
This Code is inside Extension.cs:
public static class Extensions
{
public static void AddMongoRepository<TEntity>(this ContainerBuilder builder, string collectionName)
where TEntity : IIdentifiable
=> builder.Register(ctx => new EFRepository<TEntity>(ctx.Resolve<IMongoDatabase>(), collectionName))
.As<IMongoRepository<TEntity>>()
.InstancePerLifetimeScope();
}