2014-11-19 2 views
0

저는 완벽하게 로컬에서 작동하며 Fiddler를 사용하여 철저하게 테스트 된 Azure 모바일 서비스를 보유하고 있습니다. 내가 자기 참조를 피하기 위해 설치 참조 취급Azure 모바일 서비스 게시가 작동하지 않습니다.

WebApiConfig.cs에게 루프

public static class WebApiConfig 
{ 
    public static void Register() 
    { 
     // Use this class to set configuration options for your mobile service 
     ConfigOptions options = new ConfigOptions(); 

     // Use this class to set WebAPI configuration options 
     HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options)); 

     JsonConvert.DefaultSettings =() => new JsonSerializerSettings 
     { 
      Formatting = Newtonsoft.Json.Formatting.Indented, 
      ReferenceLoopHandling = ReferenceLoopHandling.Ignore     
     }; 

     config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; 


     // To display errors in the browser during development, uncomment the following 
     // line. Comment it out again when you deploy your service for production use. 
     // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; 

     Database.SetInitializer(new MobileServiceInitializer()); 
    } 

나는이 모든 로컬 완벽하게 작동하고 말했듯이 내 상황이

public class SAServiceContext : DbContext 
{   
    private const string connectionStringName = "Name=MS_TableConnectionString"; 

    public SAServiceContext() 
     : base(connectionStringName) 
    { 
    } 

    public DbSet<Recipe> Recipes { get; set; } 
    public DbSet<Method> Methods { get; set; } 
    public DbSet<RecipeItem> Items { get; set; } 
    public DbSet<DietType> DietTypes { get; set; }... 

    protected override void OnModelCreating(DbModelBuilder modelBuilder) 
    { 
     string schema = ServiceSettingsDictionary.GetSchemaName(); 
     if (!string.IsNullOrEmpty(schema)) 
     { 
      modelBuilder.HasDefaultSchema(schema); 
     } 

     modelBuilder.Conventions.Add(
      new AttributeToColumnAnnotationConvention<TableColumnAttribute, string>(
       "ServiceTableColumn", (property, attributes) =>    attributes.Single().ColumnType.ToString())); 
    } 
    } 

매우 간단하다 나는 서비스를 게시 할 때 구름 MS_TableConnectionString 볼 수 있지만 확인 서비스가 작동하지 않습니다. 그것은 확인을 시작 내가 하나 (예 : GETSeason)를 클릭 나는 내가

PreserveReferencesHandling = PreserveReferencesHandling.Objects 

만에 시도했다

An exception has occurred while using the formatter 'JsonMediaTypeFormatter' to generate sample for media type 'application/json'. Exception message: One or more errors occurred. 

일반 오류가 발생하는 즉시하지만 내 TableControllers에서 관련된 모든 방법을 볼 수 있습니다 아무 소용이. 또한 WebApiConfig에서 호출 된 Database Initilaizer 메서드를 사용하지 않으므로 테이블이 SQL Azure에서 만들어지지 않습니다. MS Azure 포털의 로그에 오류가 표시되지 않습니다. 임 어떤 도움이 이제 푸른 포털에서 다음과 같은 오류를보고

편집 감사 붙어. MS_TableConnectionString은 Azure에서 자동으로 만들어 지므로 왜 그 말은 문제인지는 확실치 않습니다. 로컬에서는 web.config에서 connectionString을 사용합니다.

Exception = System.InvalidOperationException : 데이터베이스 초기화에 실패했습니다. 'smallacorns_v3'스키마에서 하나 이상의 개체를 초기화 할 수 없습니다. 데이터베이스 연결 문자열이 올바른지 확인하십시오. 오류에 대한 자세한 내용은 내부 예외를 참조하십시오. ---> System.InvalidOperationException : 데이터베이스 초기화가 실패했습니다. 'smallacorns_v3'스키마에서 하나 이상의 개체를 초기화 할 수 없습니다. 데이터베이스 연결 문자열이 올바른지 확인하십시오. 오류에 대한 자세한 내용은 내부 예외를 참조하십시오. ---> System.Data.SqlClient.SqlException : 사용자에게이 작업을 수행 할 권한이 없습니다.

+0

'OnModelCreating'에서 예외를 잡아 내고'Trace.WriteLine'을 사용하여 explicty로 로그온하십시오. – Abhijeet

+0

Thx 여러분의 의견에 Abhijeet. 나는 더 깊은 파고와 '데이터베이스 초기화'오류가 발생했습니다. 나는 Azure가 새로운 DB를 생성하기를 원하지 않는다. 그래서 더 자세히 조사 할 것이고 잘하면 편집을 시작할 것이다. – SWilko

답변

0

Azure SQL 데이터베이스에 연결하는 사용자는 Azure SQL 데이터베이스를 만들 수있는 권한이없는 것 같습니다.

데이터베이스 사용자에게 'db_owner'역할을 부여하면이 오류가 사라집니다.

관련 문제