|
|
I have created the EF scaffolding in my project. I have an SQL Server 2008 database attached to it via a connection string in the Web.config. I do not have an App_Data folder in the project. I have run the the web site and created a record in my scaffolded
table. I expected to see a new table added to the SQL Server database, but no, there is no table. Neither has an App_Data folder been created. Yet I can close the web site and re-open it and the record is still there.
So, where is the table containing the data being stored?
|
|
|
|
Did you check the SQLEXPRESS Instance? Is it possible that the data is still stored there?
|
|
|
|
That's why I'm asking the question. My SQL Server 2008 database has the following connection string declared
<connectionStrings>
<add name="RLSBCWebSiteDb"
connectionString="data source=MAINPC\SQLEXPRESS;Initial Catalog=RLSBCWebSite;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
This database is already storing the tables for Roles and Membership which were generated by
aspnet_regsql.exe and I expected the table generated by MvcScaffolding to be in there as well. But it's not. At least, I can't see it when I look at the list of tables through Server Explorer. It is not in any of the other
three databases to which I have connections either. So where is it?
|
|
|
|
I've found the database where the table has been stored. So now the question is: What do I need to add to the Scaffold EF generated code to make it use the above connection string? I assume something needs adding to the generated ...Context.cs
file, but what?
|
|
|
|
My question as well xiecsuk. It seems to magically put it in SQLExpress. I cannot find a reference to the connection string it uses anywhere. Plus it calls my database some very long string. How do you change this?
|
|
|
|
magically = conventions
This blog explains the conventions in EF and how to manipulate them to use the connection string you desire.
http://blogs.msdn.com/b/adonet/archive/2010/09/02/ef-feature-ctp4-dbcontext-and-databases.aspx
|
|
|
|
It would appear that EF Scaffolding has been replaced/renamed by EF Code First. There are a nunber of blogs from ScottG's blog site and the ADO.NET Team Blog that explain it fully. I have used this in my website and it weeks a treat.
|
|
|
|
@ssuing: Thanks for the link and the explanation. @xiecsuk: I suppose Code First could be considered scaffolding just for the EF piece. I wonder how they might incorporate that into this scaffolding framework.
|
|