ASP.NET MVC3 C#-数据库问题 [英] ASP.NET MVC3 C# - Database question

查看:59
本文介绍了ASP.NET MVC3 C#-数据库问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了创建MVC3应用程序的简单教程,最后得到了SDF文件数据表.现在,我已经在该解决方案上构建了自己的项目,以便进行实践并希望将其放置在服务器上,我进行了发布和数据库传输,并且除SDF中的表外,它在大多数情况下都有效,我已经重新创建了完全相同的表,并将其放置在名为ASPNETDB的默认数据库中,该数据库是我为用户控件创建项目并尝试将其重定向的,但是所有模型都搞砸了.因此,作为该领域的初学者,我一无所知...

请帮助:S

I''ve followed a simple tutorial for creating a MVC3 app, and ended up with a SDF file data table. Now, I''ve built my own project on that solution in order to practice and want to put it on my server, I did the publishing and database transfer and it works for most part, except the table that''s in SDF, I''ve recreated exactly same table and placed it in the default database named ASPNETDB which I got with creating the project for user controls and tried redirecting it but the models get all messed up. So as a beginner in this area I''m clueless how to do this...

Please help :S

推荐答案

基本上,您已经使用从连接字符串中检索到的条目连接到数据库.您需要更改此设置才能连接到真实"数据库.这是 CodeStash [
Basically, you''ve connected to your database with an entry that''s been retrieved from the connection string. You need to change this to connect to your "real" database. Here''s an example from the CodeStash[^] application.
<configuration>
  <connectionStrings>
    <add name="CodeStashEntities" 

      connectionString="metadata=res://*/DataAccess.EntityFramework.CodeStashEntities.csdl|res://*/DataAccess.EntityFramework.CodeStashEntities.ssdl|res://*/DataAccess.EntityFramework.CodeStashEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=WIN7LAP001-PC;Initial Catalog=CodeStash;Persist Security Info=True;User ID=sa;Password=sa;MultipleActiveResultSets=True;Application Name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

基本上,假设您使用的是SQL Server,则需要更改的部分是我在此处加粗的部分(数据源= ....到密码= ...). Don "尽管不要使用sa帐户来配置您的应用程序-那只是一个占位符条目,使用 sa 保护应用程序安全通常是个坏主意.

Basically, assuming you are using SQL Server, the part you need to change is the section I put into bold there (Data Source = .... through to Password = ...). Don''t use the sa account to configure your application though - that''s just a placeholder entry in there, and it''s generally a bad idea to use sa to secure your application.


这篇关于ASP.NET MVC3 C#-数据库问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆