I followed the Contoso University tutorial on asp.net and everything works fine. The next step was to repeat some things on my new website. I added an EntityDataSource object that works:
<asp:EntityDataSource ID="ProductTypeEntityDataSource" runat="server" ConnectionString="name=MyWebsite2011Entities" DefaultContainerName="MyWebsite2011Entities" EnableFlattening="False" EntitySetName="product_type">
And according to the tutorial, it is recommended that you replace ConnectionString and DefaultContainerName with ContextTypeName.
โIn the layout of the EntityDataSource control, remove the ConnectionString and DefaultContainerName attributes and replace them with the ContextTypeName =โ ContosoUniversity.DAL.SchoolEntities โattribute. This is a change you should make every time you create an EntityDataSource control, unless you need to use a connection, different from the one that is hardcoded in the feature class. "
It helped me in a textbook where they had:
<asp:EntityDataSource ID="StudentsEntityDataSource" runat="server" ContextTypeName="ContosoUniversity.DAL.SchoolEntities" EnableFlattening="False" EntitySetName="People" EnableDelete="True" EnableUpdate="True"> </asp:EntityDataSource>
The difference for me (besides the project name) is that my entity model does not fit in the DAL folder. Instead, I accepted the default folder name recommendation for Visual Web Developer. I believe this is "App_Code". But ContextTypeName = "MyWebsite2011.App_Code.MyWebsite2011Entities" does not work. When I launch the browser, it complains that the type MyWebsite2011.App_Code.MyWebsite2011Entities cannot be read.
<asp:EntityDataSource ID="ProductTypeEntityDataSource" runat="server" ContextTypeName="MyWebsite2011.App_Code.MyWebsite2011Entities" EnableFlattening="False" EntitySetName="product_type">
How do I find the correct ContextTypeName? As I said, ConnectionString and DefaultContainerName worked, so I think MyWebsite2011Entities is ok. Any clues would be appreciated because I don't know the naming convention or what to look for.
source share