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

为什么没生成lin_user用户数据呢?好多表数据都是空的 #39

Closed
GHxiaohui opened this issue May 15, 2024 · 1 comment
Closed

Comments

@GHxiaohui
Copy link

重现步骤(可选):

期望的结果是什么?

实际的结果是什么?

@luoyunchong
Copy link
Owner

这里会创建表和数据的,但好多表数据是空的是什么意思

   #region FreeSql执行同步结构SyncStructure
    public static IServiceProvider RunFreeSqlSyncStructure(this IServiceProvider serviceProvider)
    {
        using IServiceScope serviceScope = serviceProvider.CreateScope();
        var fsql = serviceScope.ServiceProvider.GetRequiredService<IFreeSql>();

        try
        {
            using var objPool = fsql.Ado.MasterPool.Get();
        }
        catch (Exception e)
        {
            Log.Error($"Message:{e.Message},StackTrace:{e.StackTrace}");
        }
        //在运行时直接生成表结构,初始化数据
        try
        {
            fsql.CodeFirst.SyncStructure(ReflexHelper.GetTypesByTableAttribute(typeof(LinUser)));
            fsql.CodeFirst.SeedData();
        }
        catch (Exception e)
        {
            Log.Error($"Message:{e.Message},StackTrace:{e.StackTrace}");
        }

        return serviceProvider;
    }
    #endregion

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