我有这个sql:
ALTER TABLE dbo.ChannelPlayerSkins
DROP CONSTRAINT FK_ChannelPlayerSkins_Channels
Run Code Online (Sandbox Code Playgroud)
但显然,在我们使用的其他一些数据库中,约束具有不同的名称.如何检查名称是否存在约束FK_ChannelPlayerSkins_Channels.
我正在尝试将我的代码第一个ID列从"int"更改为"Guid",并且在尝试运行迁移时,我收到消息:
Identity column 'CustomFieldId' must be of data type int, bigint, smallint, tinyint, or decimal or numeric with a scale of 0, and constrained to be nonnullable.
Run Code Online (Sandbox Code Playgroud)
我正在定义这样的列:
public partial class CustomField : BaseEntity
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid CustomFieldId { get; set; }
Run Code Online (Sandbox Code Playgroud)
在CustomFieldMapping.cs中映射它,如下所示:
public CustomFieldMapping()
{
//Primary key
HasKey(t => t.CustomFieldId);
//Constraints
Property(t => t.CustomFieldId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
Run Code Online (Sandbox Code Playgroud)
并且生成的迁移正在尝试执行此操作:
public override void Up()
{
DropForeignKey("dbo.CustomField", "CustomFormId", "dbo.CustomForm");
DropForeignKey("dbo.CustomData", "CustomFieldId", "dbo.CustomField");
DropForeignKey("dbo.CustomForm", "ParentFormId", "dbo.CustomForm");
DropIndex("dbo.CustomField", new[] { "CustomFormId" });
DropIndex("dbo.CustomForm", new[] { …Run Code Online (Sandbox Code Playgroud)