2012-06-13 37 views
0

我节目的网站,MVC 3.0,它使用EntityFrame工作4.0,在控制器层我有这样的:
发布MVC 3.0站点在IIS 7.0

public ViewResult Index() 
    { 
    return View(_DatabaseSMSEntities.People.ToList()); 
    } 

,并鉴于层我使用Telerik的网格:

<% 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();%> 

我在IIS 7.0中发布了它。但它不起作用。

<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=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DatabaseSMS.mdf;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" /> 
    <add name="cn1" connectionString="data source=~/ErrorsLog/Errors.db" /> 
    </connectionStrings> 

首先,我在d它出版:\ Pardis,但我得到的错误:

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: 

然后,我把它刊登在Inetup但我得到的错误。 我没有ASPNET用户在用户列表中设置安全性。

+0

那么究竟是什么不起作用可能发生么?发布自己或发布的网站? – LukeP

+0

我发现我应该添加“User Instance = True;”,但它有时会工作,并且不会再工作 –

回答

0

可能有两个问题

  1. 你忘记复制你的数据库文件(如果使用的SQL Server Compact)
  2. 您正在创建通过代码的新数据库。您不应该在部署环境中创建数据库。这可以,如果你使用的是

    System.Data.Entity.Database.SetInitializer(一些战略