小编mor*_*hai的帖子

更新数据库错误 - NuGet包(EntityFramework.SqlMigrations)

我安装了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)

entity-framework nuget-package ef-migrations

15
推荐指数
1
解决办法
2万
查看次数

实体框架代码优先 - 将两个字段联合成一个集合

我有这个型号和配置

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)映射属性?

c# entity-framework ef-code-first entity-framework-4.1

6
推荐指数
1
解决办法
2223
查看次数

异常后读取 SqlDataReader -- LIKE SSMS 结果窗格

有没有办法从不失败的情况下获取Reader对象?SqlCommand.ExecuteReaderSqlException

在 SSMS 中,对于此命令:

RAISERROR (15600, 12, 5, 'example');
SELECT   * FROM TableName
Run Code Online (Sandbox Code Playgroud)

我得到了错误信息 + 结果窗格TableName

当我SqlCommand.ExecuteReader 执行这个命令时,我得到一个SqlException,但我无法得到结果数据。有没有办法跳过异常并处理Reader对象?

c# sql-server ssms sqlcommand

1
推荐指数
1
解决办法
46
查看次数