首页 \ 问答 \ 如何在WPF应用程序中使用没有主类的init数据库(代码优先使用Entity Framework)(How to init database without main class in WPF application (code-first with Entity Framework))

如何在WPF应用程序中使用没有主类的init数据库(代码优先使用Entity Framework)(How to init database without main class in WPF application (code-first with Entity Framework))

我的数据库有点问题。 我想使用Entity Framework(代码优先)创建数据库,但是所有教程都显示了如何在控制台应用程序中使用类似的方法在main类方法中执行此操作:

exampleDb.Example.Add(); 
exampleDb.SaveChanges();

但我想在WPF应用程序中创建我的数据库。 我该怎么办?

谢谢,mm。


I have a little problem with my database. I want to create the database using Entity Framework (code-first) but all tutorials showing how to do so do it in a console application using something like this in their main class method:

exampleDb.Example.Add(); 
exampleDb.SaveChanges();

But I want to create my database in a WPF application. What should I do?

thanks, mm.


原文:https://stackoverflow.com/questions/41569437
更新时间:2024-01-24 07:01

最满意答案

显然这不是什么大问题; 我找到了一个解决方案...我使用file_get_contents()方法获取外部文件的html内容,并在setHTMLBody()中我将内容作为文本而不是文件传递

$html = sprintf(file_get_contents("../../email-templates/registration-template.html"), "myvalue");

$mime->setHTMLBody($html);

aparently it was not a big deal; i found a solution ...i get the html content of the external file using file_get_contents() method and in setHTMLBody() i passed the content as text and not as file

$html = sprintf(file_get_contents("../../email-templates/registration-template.html"), "myvalue");

$mime->setHTMLBody($html);

相关问答

更多
  • DOC1:检查是否在doc2中设置了cookie <$php $name = "Name"; if(isset($_COOKIE["nameData"])) {$name = $_COOKIE["nameData"];} ?> SOME HTML SOME HTML
  • 为什么不显示实际的
  • 属性placeholder是一个标准的HTML5属性, data-placeholder只是某个javascript插件使用的data-placeholder HTML5属性。 如果没有外部js插件, data-placeholder在placeholder工作时只会在客户端浏览器上提供HTML5支持。 Attribute placeholder is a standard HTML5 attribute and data-placeholder is just data- HTML5 attribute ...
  • 好吧,尽管规格说用户代理应该从占位符中删除新行,但我在Chrome中进行了测试并接受了新行。 你必须用/r/n替换
    : @Html.TextAreaFor(model => Model.Text, 15, 5, new { @placeholder = reviewPlaceholder.Replace("
    ", "\r\n"), @class = "span12", @style = "resize: vertical;" }) 我无法向你保证,这将永远有效,因为它不符合规格,但今 ...
  • 这可能被认为对我使用的听众数量有点过分,随意删除你认为不必要的任何人,但我已经尝试使用你的HTML结构,并给你所有想要的效果。 它应该适用于
  • 这是一个简单的ajax调用...... 对于select onchange事件,你必须使用产品ID调用javascript方法。 从该方法,您必须使用提供的id向您的nodejs服务器发出ajax请求。 在服务器上,您必须创建一个新的路由来提供请求,该请求将返回json中的值。 现在在javascript ajax方法回调中,您必须在文档元素中放置值。 希望它会对你有所帮助。 谢谢。 It is as a simple ajax call... for onchange event of select yo ...
  • 将html字符串添加到asp:Literal控件,然后将文字控件添加到占位符的控件集合中。 Add the html string to an asp:Literal control and then add the literal control to the placeholder's control collection.
  • 如果您使用计划javascript : 我为你在w3schools上创建了这个解决方案: https://www.w3schools.com/code/tryit.asp?filename=FRCFSRF5F4RW 查看ondragstart和ondragend 。 在那里调用的函数将边界设置为虚线或返回到实线。 你当然可以用css值来解决,但这是基本的实现。 如果你使用jquery ui darg: 使用Jquery中的“drag”事件可拖动: $( "#draggable" ).draggable({ ...
  • 看来你试图做的事情,你在textarea得到指示,然后如果你删除的价值,你再次得到指示。 尝试这个 var standard_message = $('#a').val(); $('#a').focus( function() { if ($(this).val() == standard_message) $(this).val(""); } ); $('#a').blur( ...
  • 显然这不是什么大问题; 我找到了一个解决方案...我使用file_get_contents()方法获取外部文件的html内容,并在setHTMLBody()中我将内容作为文本而不是文件传递 $html = sprintf(file_get_contents("../../email-templates/registration-template.html"), "myvalue"); $mime->setHTMLBody($html); aparently it was not a big deal; ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。