EF 4.3迁移重命名列而不是删除它(EF 4.3 migration renaming column instead of deleting it)
我有这个班级:
public class HabitDo{ public int? HabitId { get; set; } virtual public Habit Habit { get; set; } public int DoId { get; set; } virtual public Do Do { get; set; } public string Restriction { get; set; } public int? ObjectiveId { get; set; } public Objective Objective { get; set; } public virtual ICollection<DoObjective> Objectives { get; set; } }
该表很好,但我从代码中删除了Objective属性:
public class HabitDo{ public int? HabitId { get; set; } virtual public Habit Habit { get; set; } public int DoId { get; set; } virtual public Do Do { get; set; } public string Restriction { get; set; } public virtual ICollection<DoObjective> Objectives { get; set; } }
当从管理器控制台调用update-database时,EF会重命名ObjectiveId列而不是删除它:
EXECUTE sp_rename @objname = N'HabitDoes.ObjectiveId', @newname = N'Objective_Id', @objtype = N'COLUMN'
任何线索为什么发生这种情况?
I have this class:
public class HabitDo{ public int? HabitId { get; set; } virtual public Habit Habit { get; set; } public int DoId { get; set; } virtual public Do Do { get; set; } public string Restriction { get; set; } public int? ObjectiveId { get; set; } public Objective Objective { get; set; } public virtual ICollection<DoObjective> Objectives { get; set; } }
The table is just fine, but then I remove from code the Objective property:
public class HabitDo{ public int? HabitId { get; set; } virtual public Habit Habit { get; set; } public int DoId { get; set; } virtual public Do Do { get; set; } public string Restriction { get; set; } public virtual ICollection<DoObjective> Objectives { get; set; } }
And when calling update-database from the manager console EF renames the ObjectiveId column instead of dropping it:
EXECUTE sp_rename @objname = N'HabitDoes.ObjectiveId', @newname = N'Objective_Id', @objtype = N'COLUMN'
Any clues why this happens?
原文:https://stackoverflow.com/questions/11647025
更新时间:2023-05-27 21:05
最满意答案
我想你正在寻找
highlight
帮手 :highlight('You searched for: rails', 'rails') # => You searched for: <strong class="highlight">rails</strong>
有关更多选项,请参阅链接。
I guess you're looking for
highlight
helper:highlight('You searched for: rails', 'rails') # => You searched for: <strong class="highlight">rails</strong>
See the link for more options.
相关问答
更多-
我想你正在寻找highlight帮手 : highlight('You searched for: rails', 'rails') # => You searched for: rails 有关更多选项,请参阅链接。 I guess you're looking for highlight helper: highlight('You searched for: rails', 'rails') # => You searched f ...
-
RegEx查找所有锚标签,包括带图像的锚标签[重复](RegEx find all anchor tags, including ones with images [duplicate])[2021-05-10]
我跳过你做的检查,看看这条线是否已经存在,并且通常是这样的(这里我想用'BAR'替换'FOO'): full_path_to_read = File.expand_path('~/test1.txt') full_path_to_write = File.expand_path('~/test2.txt') File.open(full_path_to_read) do |source_file| contents = source_file.read contents.gsub!(/FOO/, ...试试.replaceWith() $(element).replaceWith(other_stuff); JQUERY is sometimes too much overhead. var location = document.getElementById('A0.R0.Work'); location.innerHTML = 'some code
';你的正则表达式不起作用的原因是显而易见的。 它只捕获一个"并跳过所有其他的但它应该停在每个位置" 。 它可以用\G令牌完成 。 由于Sublime Text正则表达式是Perl兼容(PCRE),因此regex是解决此问题的正确方法: 正则表达式: <%(?:(?!%>)[^"])*\K"|(?!\A)\G(?:(?!%>)[^"\\])*(?:\\.(?:(?!%>)[^"\\])*)*\K" 替换字符串: ' 现场演示 说明: <% # Match beginn ...如何查找和复制两个标签之间的所有内容(包括标签)(How to find & copy everything between two tags (Including tags))[2021-11-29]
你的正则表达式遗漏了我的想法。 使用.* u获取所有字符但不是换行符(换行符)尝试这样的事情(.|\n)*<\/center> 变更部分的细分 . =所有字符 | =或 \n =换行(换行) (.|\n)* =上面一行的零次或多次(贪婪,因为manny时间为posible 看看演示 如果你一次有更多的部分你可以使用 (.|\n)*?<\/center> 变更部分的细分 的? 会让它变得非贪婪,所以它会在 的第一次出现时返回 看看演示 your regex is ...与简单地在ERB(或Haml或Slim)中编写html标记相比,使用Rails标记助手将会产生相当大的开销。 当使用“动态html”(在服务器端输入创建的标记意义上)时,这通常是可接受的可读性和生产率的权衡,但如果没有插值则完全没有必要。 基本上只是使用常识--Rails标记帮助程序(及其所有衍生工具,如表单帮助程序)并不是在视图中编写HTML的完全替代,而是作为实用程序,使变量更容易和更清晰地绑定到属性和标签的内容。 它们还使编写自己的帮助器方法变得更加容易,您可以以编程方式创建HTML而不是使用字符串连 ...这是当前场景的正则表达式。 当正则表达式方法最终破解时,请记住我们警告用正则表达式解析HTML是一个愚蠢的差事。 ;) 这个: var s = "some textmultiline content\r\n\r\n for
removeanother multiline content\r\n ...
不幸的是,使用原始CSS无法解决这个问题,因为您无法使用内联CSS来定位pseduo-selectors 。 但是,可以使用JavaScript解决这个问题。 您需要做的是将以下内容添加到您的页面: ...您可以使用正则表达式执行此操作,例如: "Hello\n
\nworld".gsub(/(?im)(
\s*)+/,'
') 为了解释这一点:( (?im)部分有选项,表明匹配应该不区分大小写. 应该匹配换行符。 分组表达式(
\s*)匹配
(可选地带有空格和尾部/ )可能后跟空格,而+表示匹配该组中的一个或多个。 但是,我应该指出,通常使用正则表达式来操作HTML并不是一个好主意 - 您应该使用适当的解析器。 例如,使用Noko ...相关文章
更多- solr 4.3 win下环境搭建
- 在Tomcat部署Solr 4.3
- solr4.3+tomcat入门部署
- XWiki 4.3 正式版发布
- solr4.3之配置中文分词smartcn
- solr4.3之配置中文分词IK
- solr4.3之拼写检查SpellChecker功能
- solr4.3之检索建议suggest功能
- solr4.3纠错源码学习(一)——SpellCheckComponent
- Lucene4.3进阶开发之礼敬如来(十三)
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)