Click here to Skip to main content
15,113,245 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

1 solution

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.
    <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" />
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.
Srdjan Debic 9-May-12 9:29am
Ok, first let me apologize for bit lack of info there.

Yes I am using SQL Server 2008, I've already placed ASPNETDB database just like you did there in connection string and application properly connects to that database and roles and permissions I made all work just fine.

Problem that I have is that through this tutorial, I get additional database table in form of SDF table. Which, so far, by no means I can get to work.

Since is SDF (refers to SQL CE) instead of going around and importing it I just recreated it on server. But instead of using the separate database as my VS project did I created it inside of database ASPNETDB that is used for user/role management. So I need an advice how to make it so that I don't need the SDF for my project to work with database? Hope this was clear enough. By referring to the link I provided you should get the closer idea what is happening.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900