FreeSQL 基本使用

FreeSQL连接MySQL

安装 FeeSql相关库

FreeSQL 基本使用_第1张图片

FreeSql 基本库

FreeSql.DbContext 

FreeSql.Extensions.Linq linq语法扩展库

FreeSql.Provider.Mysql MySQL连接库

新建DbConent.cs 

    public class Base
    {
        static string connstr = @"Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;SslMode=none;Initial Catalog=sales;CharSet=utf8mb4";
        public static readonly IFreeSql db = new FreeSql.FreeSqlBuilder()
             .UseConnectionString(FreeSql.DataType.MySql, connstr)
             .UseAutoSyncStructure(true)
             .Build();

        public class DBContext : DbContext
        {
            public DbSet Users { get; set; }

            protected override void OnConfiguring(DbContextOptionsBuilder builder)
            {
                
                var sql = new FreeSql.FreeSqlBuilder()
                .UseConnectionString(FreeSql.DataType.MySql, connstr)
                .UseAutoSyncStructure(true)
                .Build();
                builder.UseFreeSql(sql);
            }
        }
    }

你可能感兴趣的:(android)