[dba-Tech] asp.net vb EF issues

Tope Mike Mike.Tope at saipem.com
Tue May 21 11:56:53 CDT 2013


Hi all
Quite different from my usual practice of using databaseadvisors as a time machine, catching up on posts months after the event, I've subscribed from work to ask for your help on a live issue. I'm in London so my afternoon will be morning for most of you.

The subject concerns a recent install of Visual Studio Express 2012 for Web now with update 2, with a  Nuget update to the Entity Framework to 5.0.0. Basically, I'm not having any luck with it. It seems to be creating the model in duplicate, then complaining of conflicts and refusing to go any further.

Please direct me to one of your other lists if you think that would be a better fit. I couldn't choose between VB and SQL server and anyway I think this list has more chance of an answer.

I've built a noddy database in SQL Server just to demonstrate the security method I want to use in my grand project, then I want to put a web front end to it using VS2012. Such problems, that I've moved now to installing AdventureWorks2008R2 and still I'm showing this problem.

Steps - have I missed something basic?
Open VS2012, create new VB web forms application AdventureWorks.
View the default.aspx, clear out the dummy text and drop an Entity Datasource on the page.
Rightclick the project and add a folder App_Code.
Rightclick App_Code and Add ADO.NET Entity Data Model, left as Model1.
Generate from database, new connection to server, database AdventureWorks2008R2, save connection settings.
Select only the Product table, and finish.
Select the Entity Datasource control and Configure Data Source, Named Connection, AdventureWorks2008R2Entities, EntitySetName Products, several fields.
Drop in a GridView, AutoFormat Brown Sugar, EntityDataSource1, sorting, paging and selection.
I've learnt to edit the web.config, replace
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
with
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
If I build the project at this point I get three warnings but no errors. They don't look like the culprit to me, but I've added them at the bottom here.

Press F5, error shows up in the browser:-
Schema specified is not valid. Errors:
App_Code.Model1.csdl(3,4) : error 0019: The EntityContainer name must be unique. An EntityContainer with the name 'AdventureWorks2008R2Entities' is already defined.
App_Code.Model1.csdl(6,4) : error 0019: Each type name in a schema must be unique. Type name 'AdventureWorks2008R2Model.Product' was already defined.

I can clear out the project and start again and it does the same. I deliberately used AdventureWorks as a fresh start and it did this the first time it ever looked at it. Anyone who has made Visual Studio work with the Entity Framework has more experience than me and I'm listening to any advice you can offer.


regards
Mike Tope

Those warnings, for completeness:-
Warning               1              The path 'G:\Documentation\VS2012\AdventureWorks\AdventureWorks\App_Code\EF.Utility.VB.ttinclude' must be either local to this computer or part of your trusted zone. If you have downloaded this template, you may need to 'Unblock' it using the properties page for the template file in File Explorer.                G:\Documentation\VS2012\AdventureWorks\AdventureWorks\App_Code\Model1.tt 0              0                AdventureWorks
Warning               2              Compiling transformation: Variable 'errors' is passed by reference before it has been assigned a value. A null reference exception could result at runtime.                G:\Documentation\VS2012\AdventureWorks\AdventureWorks\App_Code\Model1.tt 616         1                AdventureWorks
Warning               3              Compiling transformation: Variable 'lazyLoadingAttributeValue' is passed by reference before it has been assigned a value. A null reference exception could result at runtime.                G:\Documentation\VS2012\AdventureWorks\AdventureWorks\App_Code\Model1.tt 670         1                AdventureWorks
******************************************************************************************
CONFIDENTIALITY NOTICE
This e-mail and any attachment are confidential and may be privileged or otherwise protected from disclosure. It is solely intended for the person(s) named above. If you are not the intended recipient, any reading, use, disclosure, copying or distribution of all or parts of this e-mail or associated attachments is strictly prohibited. If you are not an intended recipient, please notify the sender immediately by replying to this message or by telephone and delete this e-mail and any attachments permanently from your system.


More information about the dba-Tech mailing list