asp.net mvc 3 Application is not showing data from data source, but from some cache
Just started to playing with Microsoft Visual Web Developer 2010 Express. Have created db on sql 2008 server, created edmx file, then controllers.
Everything works fine apart of not showing data from sql server. It acts like it's connected to some other data source. Because it does store data somewhere and then showing them back.
In web.config i have:
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="PlanovaniZdrojuEntities1" connectionString="metadata=res://*/Models.PlanovaniModel.csdl|res://*/Models.PlanovaniModel.ssdl|res://*/Models.PlanovaniModel.msl;provider=System.Data.SqlClient;provider connection string="data source=XPOFF2003;initial catalog=PlanovaniZdroju;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
Then in autogenerated PlanovaniModel.Context.cs:
public partial class PlanovaniZdrojuEntities1 : ObjectContext
{
public const string ConnectionString = "name=PlanovaniZdrojuEntities1";
public const string ContainerName = "PlanovaniZdrojuEntities1";
So it seams for me it should work. But it gives me different data than I have on SQL server. Like it's connecting to somewhere els开发者_开发知识库e.
Where else could I look in the project to fix this up?
Look at your connection string named: "PlanovaniZdrojuEntities1" ;data source=XPOFF2003;initial catalog=PlanovaniZdroju;
thats where your data should be coming from. Are you saying the data is NOT whats in there? If thats where you generated your entities from and didnt change anything - it has to be from that database. You can fire up sql profiler for your local machine as well and look at the connections and where the data is coming from. Do you have any other databases in app_data besides the aspnet db?
精彩评论