nickward26
asked on
Keep getting a Database Error in my WCF MVC Website.
Hello,
I have a WCF and Mvc project, the project has been split up into different sections;
DataAccess project - this is essentially a class library which has all the database functionality in (i.e. Connection strings, Database file)
Wcf middleware - this is the WCF service project.
Website
The project is essentially a Mvc Form with some textboxes and a submit button.
The problem i have is everytime I debug the project, i keep getting this error;
Cannot open database "ViewModelsContext" requested by the login. The login failed.
Login failed for user 'NicksPC\Nick.Ward'.
this is my connection string;
<add name="ViewModelsContext" connectionString="Server=. \SQLEXPRES S;AttachDB Filename=C :\Developm ent\DevPro jects\Uplo ader\Main\ Source\Fro ntEnd\Web\ Uploader.D ataAdapter \App_Data\ UploaderDB .mdf;Datab ase=Upload erDB;Trust ed_Connect ion=Yes" providerName="System.Data. SqlClient" />
public class ViewModelsContext : DbContext
{
public ViewModelsContext()
: base("ViewModelsContext")
{
Database.SetInitializer<Vi ewModelsCo ntext>(nul l);
}
protected override void OnModelCreating(DbModelBui lder modelBuilder)
{
modelBuilder.Conventions.R emove<Plur alizingTab leNameConv ention>();
base.OnModelCreating(model Builder);
}
public DbSet<Uploader.Customer> Customers { get; set; }
}
}
The connection string is stored in the App.Config file which is in the DataAccess Project
The Middleware project calls the DataAccess layer, shown;
public Customer SaveCustomerDetails(Retail Uploader.C ustomer customerDetails)
{
CustomerData cust = new CustomerData();
//cust.SaveCustomers(custo merDetails );
return cust.SaveCustomers(custome rDetails);
}
In the website project, it calls the WCF service, shown;
[HttpPost]
public ActionResult Upload(Customer cust)
{
if (ModelState.IsValid)
{
CustomerDataUpload test = new CustomerDataUpload();
test.SaveCustomerDetails(c ust);
}
return View();
}
I have also mapped the model in the textbox controls, sample shown;
<%= Html.TextBoxFor(model => model.Title, new { id = "first_name", @class = "uploader_form_input required minlength alpha" })%>
I am just abit baffled as to why it keeps complaining about the Database Connection.
Thanks,
Nick Ward
I have a WCF and Mvc project, the project has been split up into different sections;
DataAccess project - this is essentially a class library which has all the database functionality in (i.e. Connection strings, Database file)
Wcf middleware - this is the WCF service project.
Website
The project is essentially a Mvc Form with some textboxes and a submit button.
The problem i have is everytime I debug the project, i keep getting this error;
Cannot open database "ViewModelsContext" requested by the login. The login failed.
Login failed for user 'NicksPC\Nick.Ward'.
this is my connection string;
<add name="ViewModelsContext" connectionString="Server=.
public class ViewModelsContext : DbContext
{
public ViewModelsContext()
: base("ViewModelsContext")
{
Database.SetInitializer<Vi
}
protected override void OnModelCreating(DbModelBui
{
modelBuilder.Conventions.R
base.OnModelCreating(model
}
public DbSet<Uploader.Customer> Customers { get; set; }
}
}
The connection string is stored in the App.Config file which is in the DataAccess Project
The Middleware project calls the DataAccess layer, shown;
public Customer SaveCustomerDetails(Retail
{
CustomerData cust = new CustomerData();
//cust.SaveCustomers(custo
return cust.SaveCustomers(custome
}
In the website project, it calls the WCF service, shown;
[HttpPost]
public ActionResult Upload(Customer cust)
{
if (ModelState.IsValid)
{
CustomerDataUpload test = new CustomerDataUpload();
test.SaveCustomerDetails(c
}
return View();
}
I have also mapped the model in the textbox controls, sample shown;
<%= Html.TextBoxFor(model => model.Title, new { id = "first_name", @class = "uploader_form_input required minlength alpha" })%>
I am just abit baffled as to why it keeps complaining about the Database Connection.
Thanks,
Nick Ward
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER