是否可以在运行时加载EF元数据?

编程入门 行业动态 更新时间:2024-10-28 14:36:59
本文介绍了是否可以在运行时加载EF元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在运行时从数据库加载EF元数据。这种情况是否可行?首先从数据库获取数据,然后写入.ssdl,.msl和.csdl文件听起来不错。但是如何告诉EF使用我已经加载的?我需要编译它吗?

I want to load EF metadata from database at runtime. Is that scenario possible? First get the data from database, then write it to .ssdl, .msl and .csdl files sounds ok. But how to tell EF to use what I've loaded? Do I need to compile it or something like that?

推荐答案

是的,你可以这样做。

使用 MetadataWorkspace msdn.microsoft/en-us/library/cc679683( v = VS.100).aspxrel =nofollow noreferrer>构造函数,它将这些文件。

New up a MetadataWorkspace using the constructor which takes these files.

然后你可以新建一个 EntityConnection 将 MetadataWorkspace 传递给重载的构造函数,最后新增 ObjectContext

Then you can new up an EntityConnection passing the MetadataWorkspace to the overloaded constructor, and finally new the ObjectContext passing that.

所有这一切,我想知道这是否是您问题的最佳方法。

With all that said, I wonder if this is the best approach to your problem.

更多推荐

是否可以在运行时加载EF元数据?

本文发布于:2023-11-05 06:28:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560154.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   数据   EF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!