2017-12-26 22 views
0

.net 핵심 웹 API를 만들려고하지만 ı에서 내 문제의 해결책을 찾을 수 없습니다.System.ArgumentException : 초기화 문자열의 형식이 인덱스 0에서 시작하는 사양을 준수하지 않습니다. 3

전체 오류가

' "MailAlertWebApiWithEF.Data.AlertContext"'콘텍스트 타입에 대한 쿼리의 결과를 반복하는 동안 예외 데이터베이스 발생 [ERR] " ''System.ArgumentException. : 초기화 문자열의 형식은 0

내가

,536으로 기존 데이터베이스에서 해당 구성 코드를 얻을 인덱스에서 시작하는 사양에 맞지 않습니다

비계 - DbContext "서버 =; ConnectionString을"Microsoft.EntityFrameworkCore.SqlServer -OutputDir DBModels -force -v

내 구성은 다음과 같습니다

public class AlertModelConfiguration<T>:BaseEntityModelConfiguration<T,int> where T:Alert 
{ 

    public AlertModelConfiguration(ref ModelBuilder modelBuilder):base(ref modelBuilder) 
    { 
     modelBuilder.Entity<Alert>(entity => 
     { 
      //entity.HasKey(e => e.AlertId); 

      entity.Property(e => e.CreateDate).HasColumnType("datetime"); 

      entity.Property(e => e.DeleteDate).HasColumnType("datetime"); 

      entity.Property(e => e.Detail) 
       .IsRequired() 
       .HasMaxLength(2046) 
       .IsUnicode(false); 

      entity.Property(e => e.ErrorDetail) 
       .IsRequired() 
       .HasMaxLength(255) 
       .IsUnicode(false); 

      entity.Property(e => e.Title) 
       .HasMaxLength(50) 
       .IsUnicode(false); 

      entity.Property(e => e.UpdateDate).HasColumnType("datetime"); 
     }); 
    } 
} 

내 상황은 다음과 같습니다

public class AlertContext:DbContext 
    { 
    public AlertContext(DbContextOptions<AlertContext> options) 
     : base(options) 
    { 

    } 

    public virtual DbSet<Alert> Users { get; set; } 


    protected override void OnModelCreating(ModelBuilder modelBuilder) 
    { 

     new AlertModelConfiguration<Alert>(ref modelBuilder); 


     base.OnModelCreating(modelBuilder); 
    } 
} 

appsettingss.json의 내 ConnectionStrings :

ConnectionStrings": { 
    "AlertContext": "server=.;database=*****;poling=false;Connect 
Timeout=60;Integrated Security=SSPI" 

ı 디버그 모드에서 시작하면 API가 엔진 계층 안에 갇히게됩니다.

내 엔진 및 IEngine는 :

Task<CustomListEntity<Alert>> GetByIdAsync(int id); 

public Task<CustomListEntity<Alert>> GetByIdAsync(int id) 
    { 
     return CommonOperationAsync(async() => 
     { 
      var predicate = PredicateBuilder.True<Alert>(); 
      predicate = predicate.And(p => p.Id == id); 



      return new CustomListEntity<Alert>() 
      { 
       EntityList = await _alertReqository.GetAll(skip: 0, take: 10, predicate: predicate, 
        orderExpression: null, rowCount: out var count, ascending: false).ToListAsync(), 

       Count = count, 
      }; 
     }, new BusinessBaseRequest() 
     { 
      MethodBase = MethodBase.GetCurrentMethod() 
     }, BusinessUtilMethod.CheckRecordIsExist, GetType().Name); 
    } 

난 내 자신의 구성 파일을 시도했지만 결과는 동일합니다. 잘못된 것을 도와주세요.

답변

1

이 오류는 연결 문자열이 올바르지 않음을 나타냅니다.

"풀링"라는 단어에 오타가있다, 다음 연결 문자열을 시도 :

ConnectionStrings": { 
     "AlertContext": "server=.;database=*****;pooling=false; 
       Timeout=60;Integrated Security=SSPI" 

여전히 작동하지 않는 경우, 서버 및 데이터베이스 값이 확인되어 있는지 확인합니다.