I program website with MVC 3.0 which uses EntityFrame work 4.0, In controller layer I Have this:
public ViewResult Index()
{
return View(_DatabaseSMSEntities.People.ToList());
}
And in View Layer I used Telerik Grid:
<% Html.Telerik().Grid<ProjectWebsite.Models.People>(Model)
.Name("People")
.Columns(columns =>
{
columns.Bound(o => o.PersonID).Format(
"<a href='../WebPage/PersonSMSPage.aspx?personID=" + "{0}" + @"' <br/>runat=""server"">" +
"<img src='../../Content/themes/base/images/RegisterSMS.png' <br/>alt='{0}' />"<br/>
);
})
.RowAction(row =>
{
if (row.Index == 0)
{ row.DetailRow.Expanded = false; }
})
.Render();%>
I published it in IIS 7.0. But it does not work.
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="DatabaseSMSEntities" connectionString="metadata=res://*/Models.ModelDatabaseSMS.csdl|res://*/Models.ModelDatabaseSMS.ssdl|res://*/Models.ModelDatabaseSMS.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DatabaseSMS.mdf;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
<add name="cn1" connectionString="data source=~/ErrorsLog/Errors.db" />
</connectionStrings>
First, I published it in D:\Pardis, But I got error:
CREATE DATABASE permission denied in database 'master'.
An attempt to attach an auto-named database for file D:\Pardis\App_Data\DatabaseSMS.mdf failed. A database with the same name
exists, or specified file cannot be opened, or it is located on UNC share.
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: CREATE DATABASE permission denied in database 'master'.
An attempt to attach an auto-named database for file D:\Pardis\App_Data\DatabaseSMS.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Source Error:
Line 20: public ViewResult Index()
Line 21: {
Line 22: return View(_DatabaseSMSEntities.People.ToList());
Line 23: }
Line 24:
Then, I published it in Inetup but I got error. I do not have ASPNET user in user list to set security.
There might be two problems
You are creating a new database through code. You should not be creating databases in your deployment environment. This can probably happen if you are using
System.Data.Entity.Database.SetInitializer(some strategy)