locked
Best method to deploy the database first approach based application in MVC3 RRS feed

  • Question

  • User-818936891 posted

    hi,

    i am facing some problems when i am trying to deploy the MVC3 application in IIS. This application is developed on database first approach.

    Its working fine in IIS express and also working fine with visual web developer express.

    its throwing error when i have tried to deploy it on production server.

    The configurations are same. IIS 7.5, sql server 2008.

    i have added the _bin_deployableAssemblies so that it would not miss any dlls.

    Everything fine except when its calling the dbcontext.

    Please give me some solution for this.

     

    Thursday, June 23, 2011 3:25 AM

All replies

  • User181256233 posted

    Could you perhaps give us the errormessage? Otherwise its impossible to locate the problem

    Thursday, June 23, 2011 3:29 AM
  • User-818936891 posted

    Cannot open database "MyNamespace.Models.SampleContext" requested by the login. The login failed.
    Login failed for user 'IIS APPPOOL\DefaultAppPool'.

    Thursday, June 23, 2011 4:37 AM
  • User181256233 posted

    You need to set the username and password in the connectionstring or allow that user to connect to the sql server.

    When you run it in IIS Express it is executed as yourself, but when you deploy it runs as the user set on the applicationpool

    Thursday, June 23, 2011 4:46 AM
  • User-818936891 posted

    hi,

     

    can you provide me the sample connectionstring?

    Thursday, June 23, 2011 4:48 AM
  • User181256233 posted

    If you just remove "Integrated Security=true" and add "User ID=xxx;Password=xxx" instead it should work

    That is the userid and password of the sql server user.

    Thursday, June 23, 2011 4:52 AM
  • User-818936891 posted

    hi knecke,

     

    i used it already and still its throwing the same  error.

     

     

     

    Thursday, June 23, 2011 4:57 AM
  • User181256233 posted

    It says "Login failed".

    Either there is wrong username/pass combination. OR the user don't have access to the SQL Server. It is as easy as that.

    But since the errormessage say that it is using the applicationpool user i suspect you dont have userId/password in the connectionstring

    Thursday, June 23, 2011 5:09 AM
  • User-818936891 posted

    its not related to either sql server or asp.net.

     

    This is issue happened only in MVC3

     

    Thursday, June 23, 2011 7:34 AM
  • User181256233 posted

    I think you are wrong, the login still fail according to the errormessage. How does your connectionstring look like?

    Thursday, June 23, 2011 8:07 AM
  • User-818936891 posted

    come on man.

    Membership provider is working with the same sql server.

    its not working when we tried to access our database first model.

    My issue is about MVC3 not about asp.net

    Thursday, June 23, 2011 8:17 AM
  • User197322208 posted

    My issue is about MVC3 not about asp.net

    Your issue is about deploying EF, not about asp.net. Where did you deploy the application?

    Thursday, June 23, 2011 8:28 AM
  • User181256233 posted

    Why do you ask a question on a forum if you don't like the answers?

    1) Are the Membership provider using the same connectionstring as the dbcontext?

    2) If you get a Login failed error, your login failed, end of story. The connectionstring is not valid

    3) MVC is part of ASP.NET so what are your point here?

    Thursday, June 23, 2011 8:29 AM
  • User-818936891 posted

    Why do you ask a question on a forum if you don't like the answers?

    1) Are the Membership provider using the same connectionstring as the dbcontext?

    Yes. its working while i am calling login controls.

    2) If you get a Login failed error, your login failed, end of story. The connectionstring is not valid

    Not like that.

    3) MVC is part of ASP.NET so what are your point here?

    Yes. its a part. but not like the normal asp.net pages.

    Thursday, June 23, 2011 8:34 AM
  • User181256233 posted

    Man, you are not listening when i'm trying to help

    Are you connectionstring the same or do you have two of them?

    Thursday, June 23, 2011 8:35 AM
  • User-818936891 posted

    hi,

     

    i am trying to deploy it in another server which has several asp.net applications running already.

    The connectionstring works fine when i am calling from login controls.

    its failed when i am calling EF models.

    Thursday, June 23, 2011 8:36 AM
  • User-818936891 posted

    Man, you are not listening when i'm trying to help

    Are you connectionstring the same or do you have two of them?

     

    Yes both are same.

    Thursday, June 23, 2011 8:37 AM
  • User181256233 posted

    How are you referring to the connectionstring then?

    Thursday, June 23, 2011 8:38 AM
  • User-818936891 posted

    its happening only when i am using IIS. The same application is running good when i use app_data db.

    The error is coming when i am trying to deploy it over IIS. not in IIS express.

    Thursday, June 23, 2011 8:39 AM
  • User181256233 posted

    Yes, that is exaclty what i have been telling you. When you deploy the application in IIS it runs as a different user, the application pool.

    And if you have Integrated Security=true in your connectionstring it will work locally, but NOT when deployed to a server.

    Thursday, June 23, 2011 8:41 AM
  • User-818936891 posted

    //How are you referring to the connectionstring then?

     

    I am using sql server 2008 connection for membership provider and the same connectionstring is used in application services.

    Thursday, June 23, 2011 8:41 AM
  • User-818936891 posted

    Yes, that is exaclty what i have been telling you. When you deploy the application in IIS it runs as a different user, the application pool.

    And if you have Integrated Security=true in your connectionstring it will work locally, but NOT when deployed to a server.

     

    what is your solution for this.???

     

    Thursday, June 23, 2011 8:44 AM
  • User197322208 posted

    And if you have Integrated Security=true in your connectionstring it will work locally, but NOT when deployed to a server. what is your solution for this.???

    Simple: on the app pool of the application server put a user that have access rights to the SqlServer. But I doubt most hosting providers will allow you to do that...

    Thursday, June 23, 2011 8:48 AM
  • User-818936891 posted

    hi,

    Please find the error in this.

    Are you saying we can solve this only by the requested login credentials in app pool.

     

    ///Cannot open database "MyNamespace.Models.SampleContext" requested by the login. The login failed.
    Login failed for user 'IIS APPPOOL\DefaultAppPool'.///

     

    ///

    And if you have Integrated Security=true in your connectionstring it will work locally, but NOT when deployed to a server. what is your solution for this.???

    Simple: on the app pool of the application server put a user that have access rights to the SqlServer. But I doubt most hosting providers will allow you to do that...

    Thursday, June 23, 2011 8:53 AM
  • User197322208 posted

    Are you saying we can solve this only by the requested login credentials in app pool.

     

    ///Cannot open database "MyNamespace.Models.SampleContext" requested by the login. The login failed.
    Login failed for user 'IIS APPPOOL\DefaultAppPool'.///

    There are 3 variants;

    1. change the connection string to NOT use trusted identity - how my previous users said

    2. let the connection string to USE  trusted identity - change app pool identity to have access to SQL SERVER

    ( now  it is

    user 'IIS APPPOOL\DefaultAppPool'.
    )

    3. impersonate other user (that has access to SqlServer )in web.config

    <identity impersonate=true ...

    Thursday, June 23, 2011 10:10 AM
  • User-818936891 posted

    Are you saying we can solve this only by the requested login credentials in app pool.

     

    ///Cannot open database "MyNamespace.Models.SampleContext" requested by the login. The login failed.
    Login failed for user 'IIS APPPOOL\DefaultAppPool'.///

    There are 3 variants;

    1. change the connection string to NOT use trusted identity - how my previous users said

    2. let the connection string to USE  trusted identity - change app pool identity to have access to SQL SERVER

    ( now  it is

    user 'IIS APPPOOL\DefaultAppPool'.
    )

    3. impersonate other user (that has access to SqlServer )in web.config

    <identity impersonate=true ...

     

     

      <

    add name="OnlinesurveyEntities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=localhost;Initial Catalog=Onlinesurvey;Persist Security Info=True;User ID=xxx;Password=xxx;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>

     

    hi,

     

    i have placed my connectionstring.

     

    Could you suggest me whats wrong in this. the same connectionstring is working for other applications in the production server.

    Thursday, June 23, 2011 10:41 AM
  • User1173667893 posted

    That connection string doesn't look right to me.  What I do to grab a connection string is right click on my database in the Server Explorer, click properties, and copy the connection string from there.  You have to replace 'xxxxxx' with your password.

    Thursday, June 23, 2011 12:04 PM
  • User197322208 posted

    Data Source=localhost;Initial Catalog=Onlinesurvey;Persist Security Info=True;User ID=xxx;Password=xxx;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>
    Could you suggest me whats wrong in this. the same connectionstring is working for other applications in the production server.

    What's the error for this connection string?

    Thursday, June 23, 2011 12:17 PM
  • User181256233 posted
    Ryanw51: its a little special for Entity Framework. It should look that way
    Thursday, June 23, 2011 12:21 PM
  • User181256233 posted
    Your connectionstring is named OnlinesurveyEntities but the error says MyNamespace.Models.SampleContext. Are you really sure that is the connectionstring you are trying to use?
    Thursday, June 23, 2011 12:25 PM
  • User1173667893 posted

    Ryanw51: its a little special for Entity Framework. It should look that way

    Ah, I guess I've never looked at the connection string for database first with EF.

    datasource=localhost doesn't seem right to me.  You can certainly do it, but I'm not sure why you would want to restrict your application to the same server as the database, especially for development and maintenance.

    Thursday, June 23, 2011 2:24 PM
  • User-981899747 posted

    Please post your web.config.

    Thursday, June 23, 2011 3:24 PM
  • User-818936891 posted
    Data Source=localhost;Initial Catalog=Onlinesurvey;Persist Security Info=True;User ID=xxx;Password=xxx;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>
    Could you suggest me whats wrong in this. the same connectionstring is working for other applications in the production server.
    What's the error for this connection string? hi, i have posted my connectionstring here and i have used the same credentials which other applications are using. i don't think how many persons really worked in database first approach here. Thats why i am posting again and again.
    Friday, June 24, 2011 3:25 AM
  • User-818936891 posted
    //That connection string doesn't look right to me. What I do to grab a connection string is right click on my database in the Server Explorer, click properties, and copy the connection string from there. You have to replace 'xxxxxx' with your password. // Nobody will place their credentials in any open posts.
    Friday, June 24, 2011 3:27 AM
  • User-818936891 posted

    Ryanw51: its a little special for Entity Framework. It should look that way

    Ah, I guess I've never looked at the connection string for database first with EF.

    datasource=localhost doesn't seem right to me.  You can certainly do it, but I'm not sure why you would want to restrict your application to the same server as the database, especially for development and maintenance.

     

     

    Have you worked with asp.net before???

    Friday, June 24, 2011 3:28 AM
  • User181256233 posted
    Sathesh: how do you use your connectionstring? Can you show some code where you use an instance of your entitymodel? Do you pass the connectionstringname into the constructor? I don't think its using that connectionstring since it tries using integrated security, and you dont have that in your connectionstring
    Friday, June 24, 2011 3:46 AM
  • User-818936891 posted

    knecke,

    When you use edmx model, the visual studio will allow you to pull the schema details of tables.

    Based on this edmx, you can create model classes through ADO.NET poco entity generator.

    It will create dbcontext files when you create controller for a model class.

    public partial class OnlinesurveyEntities : ObjectContext

        {

    public const string ConnectionString = "name=OnlinesurveyEntities";

    public const string ContainerName = "OnlinesurveyEntities";

            #region Constructors

    public OnlinesurveyEntities():base(ConnectionString, ContainerName){

    this.ContextOptions.LazyLoadingEnabled = true; }

    public OnlinesurveyEntities(string connectionString):base(connectionString, ContainerName){
    this.ContextOptions.LazyLoadingEnabled = true;    }

    public OnlinesurveyEntities(EntityConnection connection) :base(connection, ContainerName) {

    this.ContextOptions.LazyLoadingEnabled = true;

            }

    }

     

    This is the class using the objectcontext. These files are created through MVC only. its running now perfectly in my machine.

    i have changed the connectionstring with the server credentials. But it was not working when i tried to run in application pool.

    Then i tried custom identity and it is running good now.

     

    The same MVC application is giving error when we call data.

    The same error. The deployment server has several asp.net applications running. But this is the first MVC3 application hosted on that deployment server.

    The server is windows server 2008.

    we have tried the custom identity, network service, local system etc. Nothing gave us the solution thats the reason why i posted here.

    I think i have explained everything.

    Friday, June 24, 2011 4:31 AM
  • User-818936891 posted

    please read the below link before answer my question.

    thanks in advance.

    http://forums.asp.net/t/1662448.aspx/1?RE+MVC+3+Connection+String+without+SQLEXPRESS

    Friday, June 24, 2011 4:39 AM
  • User181256233 posted
    That is exactly what i wrote to you in an earlier post. The name of the connectionstring is wrong. By convention you need to rename it to the fully qualified name of the context class. Namespace + dbcontextclassname
    Friday, June 24, 2011 7:01 AM
  • User-818936891 posted

    no knecke.

    if it is so then why no errors coming in my local machine?

    Its all about the IIS. I guess IIS configuration is the issue. But i don't know where it is.

    Friday, June 24, 2011 7:29 AM
  • User181256233 posted
    If you know what the problem is, go fix it yourself and stop acting stupid. You get a lot of suggestion from answers here and you dont even try them?? I have over 10 years of experience in this so i think you should at least try what i suggest to you! The problem is NOT ( read again: NOT) in IIS. The problem is probably whats installed regarding sqlexpress on the liveserver since ef makes some convention about where to connect. So please, if you really want help with this, do as we say to you: You have two option: 1) Rename your connectionstring keyname to the fully qualified name of the dbcontext or 2) Pass the connectionstring or the name of the connectionstring into the constructor of the entitymodel where you use it. If you dont try any of these we can skip this thread since you already think you know the answer, sorry
    Friday, June 24, 2011 7:47 AM
  • User-818936891 posted

    I think you are wrong, the login still fail according to the errormessage. How does your connectionstring look like?

     

    No. The connectionstring which uses the membership provider is working.

    The same connectionstring which is for entity framework is not working.

    If the connectionstring is wrong, how could we able to use login controls. The login for the web application is perfect.

    if someone tried to access other than membership pages, it will throw errors.

    Friday, June 24, 2011 7:52 AM
  • User-818936891 posted

    If you know what the problem is, go fix it yourself and stop acting stupid. You get a lot of suggestion from answers here and you dont even try them?? I have over 10 years of experience in this so i think you should at least try what i suggest to you! The problem is NOT ( read again: NOT) in IIS. The problem is probably whats installed regarding sqlexpress on the liveserver since ef makes some convention about where to connect. So please, if you really want help with this, do as we say to you: You have two option: 1) Rename your connectionstring keyname to the fully qualified name of the dbcontext or 2) Pass the connectionstring or the name of the connectionstring into the constructor of the entitymodel where you use it. If you dont try any of these we can skip this thread since you already think you know the answer, sorry

     

    Have you worked with MVC before???

    From the beginning onwards, you were talking about asp.net and i gave the exact picture of problem.

    if you don't know something then keep quiet.

    i really don't know the answer thats why i am trying to find this out.

    i have tried everything thats why i posted my question here.

    if you have 10 years of experience in asp.net, then you just prove me with real coding.

    There are several persons facing the same problem while using the database first approach.

    Have you ever heard about database first approach?

     

    Sorry moderators, his post needs this kinda reply.

    Friday, June 24, 2011 8:04 AM
  • User197322208 posted

    @Sathesh_Pandian

    I do not see that you are following either my suggestion ( from the post I have listed 3 variants of modifying connection string), neither Knecke's ( that said, more, that in web.config the connection name is incorrect relative to asp.net) . If you are following and getting SAME ERROR as the beginning of this post, please tell. If you are following and getting A NEW ERROR as the beginning of this post, please tell.

    More, replying this way to Knecke, that have helped many people in the past and it's trying to help you, is NOT helpfull.

    Friday, June 24, 2011 8:15 AM
  • User-818936891 posted

    @Sathesh_Pandian

    I do not see that you are following either my suggestion ( from the post I have listed 3 variants of modifying connection string), neither Knecke's ( that said, more, that in web.config the connection name is incorrect relative to asp.net) . If you are following and getting SAME ERROR as the beginning of this post, please tell. If you are following and getting A NEW ERROR as the beginning of this post, please tell.

    More, replying this way to Knecke, that have helped many people in the past and it's trying to help you, is NOT helpfull.

     

    i have followed your suggestion. i am getting the same error from the beginning.

    The same MVC application works fine in my windows 7 machine but its giving error when i am trying to access the entity models.

    i have tried all your suggestions too. he said my connectionstring is wrong. thats why i posted it here and i have explained how i have created the models and views in one reply.

     

    Friday, June 24, 2011 8:20 AM
  • User197322208 posted

    i have followed your suggestion. i am getting the same error from the beginning.

    did you modified the app pool user? did you modified the connection string? did you add oin web.confiug the identity ?

    However, if it is the IDENTICAL SAME ERROR , I assume that you do not use this connection string through the application. Please remove from web.config and tell the whole error stack trace.

    Friday, June 24, 2011 9:52 AM
  • User-818936891 posted

    @Sathesh_Pandian

    I do not see that you are following either my suggestion ( from the post I have listed 3 variants of modifying connection string), neither Knecke's ( that said, more, that in web.config the connection name is incorrect relative to asp.net) . If you are following and getting SAME ERROR as the beginning of this post, please tell. If you are following and getting A NEW ERROR as the beginning of this post, please tell.

    More, replying this way to Knecke, that have helped many people in the past and it's trying to help you, is NOT helpfull.

    i have removed the connectionstring and now i got an error. See the error below.

     

    A network-related or instance-specific error occurred while establishing
    a connection to SQL Server. The server was not found or was not accessible.
    Verify that the instance name is correct and that SQL Server is configured to
    allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error
    Locating Server/Instance Specified)

    Friday, June 24, 2011 10:23 AM
  • User197322208 posted

    A network-related or instance-specific error occurred while establishing
    a connection to SQL Server. The server was not found or was not accessible.
    Verify that the instance name is correct and that SQL Server is configured to
    allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error
    Locating Server/Instance Specified)

    Please remove the WHOLE error handler and let the error stack see through the application ...

    Friday, June 24, 2011 10:25 AM
  • User-818936891 posted

    A network-related or instance-specific error occurred while establishing
    a connection to SQL Server. The server was not found or was not accessible.
    Verify that the instance name is correct and that SQL Server is configured to
    allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error
    Locating Server/Instance Specified)

    Description:
    An unhandled exception occurred during the execution of the current web
    request. Please review the stack trace for more information about the error and
    where it originated in the code.

    Exception Details:
    System.Data.SqlClient.SqlException: A network-related or instance-specific
    error occurred while establishing a connection to SQL Server. The server was not
    found or was not accessible. Verify that the instance name is correct and that
    SQL Server is configured to allow remote connections. (provider: SQL Network
    Interfaces, error: 26 - Error Locating Server/Instance
    Specified)

    Source Error:

    An unhandled exception was generated during the execution of the
    current web request. Information regarding the origin and location of the
    exception can be identified using the exception stack trace below.

    Stack Trace:

    [SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
       System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5009598
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
       System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) +341
       System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +129
       System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +270
       System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
       System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232
       System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
       System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33
       System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524
       System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
       System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479
       System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
       System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
       System.Data.SqlClient.SqlConnection.Open() +125
       System.Data.SqlClient.SqlProviderServices.UsingConnection(SqlConnection sqlConnection, Action`1 act) +85
       System.Data.SqlClient.SqlProviderServices.UsingMasterConnection(SqlConnection sqlConnection, Action`1 act) +349
       System.Data.SqlClient.SqlProviderServices.GetDbProviderManifestToken(DbConnection connection) +265
       System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +34
    
    [ProviderIncompatibleException: The provider did not return a ProviderManifestToken string.]
       System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +163
       System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) +35
       System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +159
       System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +50
       System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +117
       System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +423
       System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +17
       System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +63
       System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() +15
       System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() +40
       OnlineSurvey.Controllers.QuestionaireController.Index(QueryParams query) in D:\azure\interviewProcess\OnlineSurvey\OnlineSurvey\Controllers\QuestionaireController.cs:24
       lambda_method(Closure , ControllerBase , Object[] ) +108
       System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
       System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
       System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
       System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
       System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
       System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
       System.Web.Mvc.Controller.ExecuteCore() +116
       System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
       System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
       System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
       System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
       System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
       System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
       System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
       System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8836913
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
    
    Friday, June 24, 2011 10:32 AM
  • User197322208 posted

    please list what it is at

     OnlineSurvey.Controllers.QuestionaireController.Index(QueryParams query) in D:\azure\interviewProcess\OnlineSurvey\OnlineSurvey\Controllers\QuestionaireController.cs:24
    and how do you open the connection ( are you using SqlAzure?)
    Friday, June 24, 2011 11:24 AM
  • User-981899747 posted

    Sathesh, can you please post your web.config file?

    Friday, June 24, 2011 1:12 PM
  • User-818936891 posted

    please list what it is at

     OnlineSurvey.Controllers.QuestionaireController.Index(QueryParams query) in D:\azure\interviewProcess\OnlineSurvey\OnlineSurvey\Controllers\QuestionaireController.cs:24
    and how do you open the connection ( are you using SqlAzure?)

    hi,

    sorry for the late. i haven't initialised anything. i have used the default features which available with the MVC3.

    i am not using sql azure.

    This is the code where the dbcontext is making calls to the db server.

    Friday, July 1, 2011 3:10 AM
  • User197322208 posted

    must be something at

    D:\azure\interviewProcess\OnlineSurvey\OnlineSurvey\Controllers\QuestionaireController.cs:24
    ....

    Friday, July 1, 2011 3:18 AM
  • User-818936891 posted

    must be something at

    D:\azure\interviewProcess\OnlineSurvey\OnlineSurvey\Controllers\QuestionaireController.cs:24
    ....

     

    private QuestionaireContext db = new QuestionaireContext();

     

    In the 24th line, i am calling the db context.

    db.Questionaires

    I am sure there is nothing wrong in the code because its running in my local windows 7 machine. i here attached my dbconetext for this controller.

    public class QuestionaireContext : DbContext

        {     

    // You can add custom code to this file. Changes will not be overwritten.


           

    //


           

    // If you want Entity Framework to drop and regenerate your database


           

    // automatically whenever you change your model schema, add the following


           

    // code to the Application_Start method in your Global.asax file.


           

    // Note: this will destroy and re-create your database with every model change.


           

    //


           

    // System.Data.Entity.Database.SetInitializer(new System.Data.Entity.DropCreateDatabaseIfModelChanges<OnlineSurvey.Models.QuestionaireContext>());


           

    public DbSet<Questionaire> Questionaires { get; set; }

        }

     

    Friday, July 1, 2011 3:31 AM
  • User197322208 posted

    private QuestionaireContext db = new QuestionaireContext();
    I am sure there is nothing wrong in the code because its running in my local windows 7 machine. i here attached my dbconetext for this controller.

    You are calling AGAIN the default constructor of DBContext without ANY connection string and rely on your default Windows Identity.

    Modify your code to call with a connection that you pass from asp.net app via the reading of the web.config

    Friday, July 1, 2011 3:49 AM
  • User-818936891 posted

    Sathesh, can you please post your web.config file?

     

    <?

    xml version="1.0"?>

    <!--

      For more information on how to configure your ASP.NET application, please visit

      http://go.microsoft.com/fwlink/?LinkId=152368

     

    -->

    <

    configuration>

      <

    connectionStrings>

        <

    remove name="LocalSqlServer"/>

        <

    add name="ApplicationServices" connectionString="Data Source=192.120.111.15\MSSQLSERVER2008;Initial Catalog=Onlinesurvey;Persist Security Info=True;User ID=xyz;Password=xyz" providerName="System.Data.SqlClient"/>

        <

    add name="OnlinesurveyEntities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=192.120.111.15\MSSQLSERVER2008;Initial Catalog=Onlinesurvey;Persist Security Info=True;User ID=xyz;Password=xyz;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>

      </

    connectionStrings>

      <

    appSettings>

        <

    add key="webpages:Version" value="1.0.0.0"/>

        <

    add key="ClientValidationEnabled" value="true"/>

        <

    add key="UnobtrusiveJavaScriptEnabled" value="true"/>

      </

    appSettings>

      <

    system.web>

        <

    compilation debug="true" targetFramework="4.0">

          <

    assemblies>

            <

    add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

            <

    add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

            <

    add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

            <

    add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

            <

    add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

            <

    add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

          </

    assemblies>

        </

    compilation>

        <

    authentication mode="Forms">

          <

    forms loginUrl="~/Account/LogOn" timeout="2880"/>

        </

    authentication>

        <

    membership>

          <

    providers>

            <

    clear/>

            <

    add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>

          </

    providers>

        </

    membership>

        <

    profile>

          <

    providers>

            <

    clear/>

            <

    add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>

          </

    providers>

        </

    profile>

        <

    roleManager enabled="true">

          <

    providers>

            <

    clear/>

            <

    add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider"/>

            <

    add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider"/>

          </

    providers>

        </

    roleManager>

        <

    pages>

          <

    namespaces>

            <

    add namespace="System.Web.Helpers"/>

            <

    add namespace="System.Web.Mvc"/>

            <

    add namespace="System.Web.Mvc.Ajax"/>

            <

    add namespace="System.Web.Mvc.Html"/>

            <

    add namespace="System.Web.Routing"/>

            <

    add namespace="System.Web.WebPages"/>

          </

    namespaces>

        </

    pages>

        <

    authorization>

          <

    allow users="*"/>

        </

    authorization>

      </

    system.web>

      <

    system.webServer>

        <

    validation validateIntegratedModeConfiguration="false"/>

        <

    modules runAllManagedModulesForAllRequests="true"/>

      </

    system.webServer>

      <

    runtime>

        <

    assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

          <

    dependentAssembly>

            <

    assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>

            <

    bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0"/>

          </

    dependentAssembly>

        </

    assemblyBinding>

      </

    runtime>

      <

    system.data>

        <

    DbProviderFactories>

          <

    remove invariant="System.Data.SqlServerCe.4.0"/>

          <

    add name="Microsoft SQL Server Compact Edition Client Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact Edition Client 4.0" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>

        </

    DbProviderFactories>

      </

    system.data>

    </

    configuration>

    Friday, July 1, 2011 5:40 AM