我有一个为我公司提供实习生网站的项目.我在Code First项目中使用MVC5和Entity Framework 6.
这是我公司的内联网,所以我想要两个数据库.1在生产(发布).1在dev(调试)中.
我编辑了Web.config,Web.Debug.config和Web.Release.config这样的文件:
Web.Config中
<connectionStrings>
<add name="Connexion" connectionString="Data Source=[MYSQLSERVER];Initial Catalog=Intranet;Persist Security Info=True;User ID=[MYUSER];Password=[MYPASS]" providerName="System.Data.SqlClient"/>
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
Web.Debug.Config
<connectionStrings>
<add name="Connexion" connectionString="Data Source=[MYSQLSERVER];Initial Catalog=Intranet;Persist Security Info=True;User ID=[MYUSER];Password=[MYPASS]" providerName="System.Data.SqlClient"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
Web.Release.config
<connectionStrings>
<add name="Connexion" connectionString="Data Source=[MYSQLSERVER];Initial Catalog=IntranetRelease;Persist Security Info=True;User ID=[MYUSER];Password=[MYPASS]" providerName="System.Data.SqlClient"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
当我在发布mod中使用Web Deploy部署我的项目时,所有工作都已完成,最终的Web.Config具有良好IntranetRelease的目录价值.
我的问题是我的网站不工作导致数据库IntranetRelease没有从Intranet数据库更新.
我已经制作了一个完美的副本Intranet并手动创建IntranetRelease.它工作,但当人们将使用网站导致所有数据将在IntranetRelease数据库上时,我不能这样做.
我已经尝试在我的项目中进行Add-Migration xxx释放模式,但它没有改变任何东西.
目标是这样的:
当发布内部网正在工作时,我在dev数据库上工作.当我的所有更改都适合发布时,我想部署一个带有Web Deploy的新版本,并使用我的更改do something更新IntranetRelease数据库,而不会丢失任何数据.
感谢您的帮助,抱歉我的英语不好.
c# asp.net-mvc entity-framework entity-framework-6 asp.net-mvc-5
我花了一天的时间在互联网上搜索我的问题的解决方案但没有成功......理论上这似乎很简单.
我在XAML中有一个RichTextBox.我在我的数据库中有一个名为"content"的字段"LongText"
我只是希望我的数据库以简单的样式(粗体,斜体,下划线)保存RichTextBox的内容,并且我可以调用我的数据库,填充我的数据库中存储的RichTextBox内容,同时保持文本的样式.
之后,我将不得不将这些数据显示为博客,但是......必须已经成功保存并加载数据.
XAML:
<RichTextBox x:Name="nameTextEditor" TabIndex="2" Grid.Row="2" SpellCheck.IsEnabled="True">
Run Code Online (Sandbox Code Playgroud)
C#
FlowDocument doc = new FlowDocument();
StringReader sr = new StringReader(monArticle.Content);
XmlReader xmlReader = XmlReader.Create(sr);
Section sec = XamlReader.Parse(monArticle.Content) as Section;
while (sec.Blocks.Count > 0)
{
var block = sec.Blocks.FirstBlock;
sec.Blocks.Remove(block);
doc.Blocks.Add(block);
}
nameTextEditor.Document = doc;
Run Code Online (Sandbox Code Playgroud)
不要使用错误:"Exception XamlParseException""Donnéesnonvalides au niveau racine.Ligne 1,position 1."
这不是我尝试的唯一代码,但是我在不理解单词的情况下进行测试...为什么"获取RichTextBox的内容"并"在我的数据库中发送"并不容易?
谢谢你的帮助
我在我的网站上使用侧边栏,其中包含来自我的数据库的统计数据和静态数据,如链接和其他文本.
在我_Layout.cshtml,我Html.RenderAction("SidebarPV", "Home");用来调用侧边栏.
侧边栏是使用ViewModel进行统计的部分视图.
SidebarPV在我的HomeController喜欢中生成:
public ActionResult SidebarPV() {
SidebarViewModel viewmodel = new SidebarViewModel();
DateTime now = DateTime.Now;
viewmodel.stat_data1 = db.Table1.Where(e => e.DateDeb <= now && e.DateFin >= now).Count();
viewmodel.stat_data2 = db.Table2.Where(c => c.DateDeb <= now && c.DateFin >= now).Count();
return PartialView("SidebarPV", viewmodel);
}
Run Code Online (Sandbox Code Playgroud)
它就像一个魅力,但我不需要所有视图的统计数据,只有 /Home/Index
因此,当ser不在网站索引上时,我想"评论"统计数据生成.
谢谢你的建议.
编辑(解决方案,感谢krillgar):
我写的是我的 _Layout
@{
var isHome = ViewContext.RouteData.Values["controller"].ToString().ToUpper() == "HOME";
var isIndex = ViewContext.RouteData.Values["action"].ToString().ToUpper() == "INDEX";
if (isHome && isIndex) {
Html.RenderAction("SidebarPV", "Home"); …Run Code Online (Sandbox Code Playgroud)