locked
Problem while EF code first RRS feed

  • Question

  • User-436496080 posted

    I am using EF Code First to create a database. But when I executed the following code, I got exception "An exception of type 'System.Data.Entity.Core.EntityException' occurred in mscorlib.dll but was not handled in user code".

    protected void Page_Load(object sender, EventArgs e)
    {
        using (ModelFirstBloggingContext m = new ModelFirstBloggingContext())
        {
            var query = from v in m.Blogs
                        select v;
            grid1.DataSource=query.ToList();
            grid1.DataBind();
        }
    }

    Exception Details:

    Exception:Caught: "Cannot open database "ModelFirst.Blogging" requested by the login. The login failed.
    Login failed for user 'AK\Ajay'." (System.Data.SqlClient.SqlException)
    A System.Data.SqlClient.SqlException was caught: "Cannot open database "ModelFirst.Blogging" requested by the login. The login failed.
    Login failed for user 'AK\Ajay'."
    Time: 2/22/2014 11:32:24 AM
    Thread:Worker Thread[6164]

    Saturday, February 22, 2014 1:08 AM

Answers