我安装了EntityFramework.SqlMigrations NuGet Package,我收到此错误.它在过去和某种程度上对我有用,现在它不起作用.
PM> update-database
The term 'update-database' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:16
+ update-database <<<<
+ CategoryInfo : ObjectNotFound: (update-database:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud) 我有这个型号和配置
public class Person
{
public int? FatherId { get; set; }
public virtual Person Father { get; set; }
public int? MotherId { get; set; }
public virtual Person Mother { get; set; }
public virtual List<Person> Childs { get; set; }
}
class PersonConfiguration : EntityTypeConfiguration<Person>
{
public PersonConfiguration()
{
HasOptional(e => e.Father).WithMany(e => e.Childs)
.HasForeignKey(e => e.FatherId);
HasOptional(e => e.Mother).WithMany(e => e.Childs)
.HasForeignKey(e => e.MotherId);
}
}
Run Code Online (Sandbox Code Playgroud)
我得到这个类型是初始的错误.
指定的架构无效.错误:(151,6):错误0040:在名称空间ExamModel(Alias = Self)中未定义类型Person_Father.
有没有办法Childs通过两个属性(motherId和fatherId)映射属性?
有没有办法从不失败的情况下获取Reader对象?SqlCommand.ExecuteReaderSqlException
在 SSMS 中,对于此命令:
RAISERROR (15600, 12, 5, 'example');
SELECT * FROM TableName
Run Code Online (Sandbox Code Playgroud)
我得到了错误信息 + 结果窗格TableName。
当我SqlCommand.ExecuteReader 执行这个命令时,我得到一个SqlException,但我无法得到结果数据。有没有办法跳过异常并处理Reader对象?