Home

Awesome

Zxw.Framework.NetCore

Build Status

基于EF Core的Code First模式的DotNetCore快速开发框架

Nuget [最新版本:6.1.0]

Zxw.Framework.NetCore

开发环境

支持的数据库

日志组件

DI组件

AOP缓存组件使用

本项目采用的AOP中间件 :AspectCore.Extensions.Cache

示例

.net framework版本地址

项目说明

更新日志

2022/11/20

2019/12/17

services.AddCoreX(config=> { })

2019/09/16

2019/09/15

2019/08/11

a.启用代码生成器


//启用代码生成器
services.UseCodeGenerator(new CodeGeneratorOption());

b.使用代码生成器


//CodeFirst---根据model生成其他各层的代码
dbContext.CodeFirst().GenerateAll(ifExsitedCovered:true);

//DbFirst---根据现有数据表生成各层代码
dbCOntext.DbFirst().GenerateAll(ifExsitedCovered:true);

2019/04/25

2019/04/18

    //注入数据库上下文
    services.AddDbContextFactory(factory =>
    {
        factory.AddDbContext<PostgreSQLDbContext>("db1", new DbContextOption(){ConnectionString = "User ID=postgres;Password=123456;Host=localhost;Port=5432;Database=ZxwPgDemo;Pooling=true;" });
        factory.AddDbContext<SqlServerDbContext>("db2", new DbContextOption() { ConnectionString = "" });
        factory.AddDbContext<MongoDbContext>("db3", new DbContextOption() { ConnectionString = "" });
    });


    //获取
    public class TestController
    {
        public IDbContextCore DbContext1 { get; set; }
        public IDbContextCore DbContext2 { get; set; }
        public IDbContextCore DbContext3 { get; set; }

        public TestController(DbContextFactory factory)
        {
            DbContext1 = factory.GetDbContext("db1");
            DbContext2 = factory.GetDbContext("db2");
            DbContext3 = factory.GetDbContext("db3");
        }

        public void Run()
        {
            var db = DbContext1.GetDatabase();
            Console.WriteLine();
        }
    }
public class TestRepository: BaseRepository<MongoModel, ObjectId>, IMongoRepository
    {
        [FromDbContextFactory("db1")]
        public IDbContextCore DbContext1 { get; set; }
        [FromDbContextFactory("db2")]
        public IDbContextCore DbContext2 { get; set; }
        [FromDbContextFactory("db3")]
        public IDbContextCore DbContext3 { get; set; }



        public void Run()
        {
            Console.WriteLine("Over!");
        }

        public TestRepository(IDbContextCore dbContext) : base(dbContext)
        {
        }
    }

2018/09/24

2018/08/26

2018/07/06 合并dev分支到master

开源协议