惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
WordPress大学
WordPress大学
IT之家
IT之家
G
Google Developers Blog
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
博客园 - 三生石上(FineUI控件)
Engineering at Meta
Engineering at Meta
Martin Fowler
Martin Fowler
V
V2EX
爱范儿
爱范儿
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog
V
Visual Studio Blog
有赞技术团队
有赞技术团队
I
InfoQ
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网

博客园 - Yu

Illegal characters in path 依赖注入的 Singleton、Scoped、Transient vs2015 编译报错:The project references NuGet package(s) that are missing on this computer... discuz 迁移 uc_server 报错 The timeout period elapsed prior to completion of the operation or the server is not responding. 微信小程序笔记 xmlns 与 targetNamespace 的解释 Ubuntu64 apache2+lvs+Keepalived NPOI CellStyle 设置 mysql --initialize specified but the data directory has files in it select2 多选设置默认值 VS 2015 IDE 不支持 MS SQL 2000 生成 dbml Ajax 如何执行 Response.Redirect ng 发生 Error: ELOOP: too many symbolic links encountered... jquery call cross-domain webapi owin self-host HtmlAgilityPack 使用 微信 oauth2 两次回调 vs2015 使用 Eazfuscator.NET 3.3 The requested page cannot be accessed because the related configuration data for the page is invalid.
EF 热加载 Winform/Asp.net
Yu · 2017-02-14 · via 博客园 - Yu
public partial class Form1 : Form
    {
        BackgroundWorker worker = new BackgroundWorker();
        xxContext context_ = null;
        public Form1()
        {
            InitializeComponent();
            worker.DoWork += Worker_DoWork;
            worker.RunWorkerCompleted += Worker_RunWorkerCompleted;
            worker.RunWorkerAsync();
        }

        private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
           
        }

        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            context_ = new xxContext();
            var objectContext = ((IObjectContextAdapter)dbcontext_).ObjectContext;
            var mappingCollection = (StorageMappingItemCollection)objectContext.MetadataWorkspace.GetItemCollection(DataSpace.CSSpace);
            mappingCollection.GenerateViews(new List<EdmSchemaError>());
        
        }

    }
public class InitModule : IHttpModule
    {
        public static bool flag = false;

        #region IHttpModule Members

        public void Dispose()
        {
        }

        public void Init(HttpApplication context)
        {
            context.BeginRequest += Context_BeginRequest;
        }

        private void Context_BeginRequest(object sender, EventArgs e)
        {
            if (!flag)
            {
                flag = true;
                Task.Factory.StartNew(() => {
                    var context = new xxContext();
                    var objectContext = ((IObjectContextAdapter)context).ObjectContext;
                    var mappingCollection = (StorageMappingItemCollection)objectContext.MetadataWorkspace.GetItemCollection(DataSpace.CSSpace);
                    mappingCollection.GenerateViews(new List<EdmSchemaError>());
                });
            }
        }

        #endregion

    }
web.config:

<system.webServer> <modules> <add name="init" type="InitModule"/> </modules> </system.webServer>

posted @ 2017-02-14 14:56  Yu  阅读(566)  评论()    收藏  举报