Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 3rd, 2015, 12:33 PM
Authorized User
Points: 91, Level: 1
Points: 91, Level: 1 Points: 91, Level: 1 Points: 91, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2015
Location: rural Minnesota
Posts: 19
Thanks: 6
Thanked 0 Times in 0 Posts
Default Publishing with EF??

I published working code to a web server. The code that uses regular connection strings works fine. The code that uses EF gets compile errors. I created a new database on the webserver using the SQL query I used to create the test database. I built the EF model directly on the web server. I had to change the name of the database itself and the entity and model are different, but everything else is the same.
Specifically, I get a compile error with an AddEdit page essentially like p 583.
Everything appears to be OK up to myEntities.AddToReviews(myReviews). It doesn't recognize AddToReviews. Where do I look to find the problem? Thank you.
Reply With Quote
  #2 (permalink)  
Old October 4th, 2015, 07:40 AM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Can you provide more information. For example, what does "I built the EF model directly on the web server" mean? Does it mean you have Visual Studio on the server? If so, which version? Also, what's the error you are getting?

My guess is that the issue is caused by different versions of EF where your server uses a newer version by default, but it's had to tell without a lot more information.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old October 4th, 2015, 02:13 PM
Authorized User
Points: 91, Level: 1
Points: 91, Level: 1 Points: 91, Level: 1 Points: 91, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2015
Location: rural Minnesota
Posts: 19
Thanks: 6
Thanked 0 Times in 0 Posts
Default

Thank you. The server does not have VS, so the different version of EF was a good hint. After a lot of screwing around, I got a specific error: Unable to load the specified metadata resource.
In designer.vb:
MyBase.New("name=WriteOnTwoADOEntities", "WriteOnTwoADOEntities")
The bottom of the error page is:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248. That means that the Entity Framework version of the server is 4.0, right?
The config file entityframework section includes: EntityFramework, Version=5.0.0.0 and httpRuntime targetFramework="4.5"

So... either the server needs to be updated, or I need to specify version 4 to VS, right? If that's right, how do I do that?
I optimistically tried changing the values in config to 4.0, but that didn't work. Thank you again.
Reply With Quote
  #4 (permalink)  
Old October 4th, 2015, 02:40 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

>> Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248. That means that the Entity Framework version of the server is 4.0, right?

No, it does not. That's the version number from the ASP.NET runtime.

I still don't understand the problem, so can you provide more information as request earlier? How can you "[build] the EF model directly on the web server" without having VS installed?

You can tell which EF version you're using by looking at pacakges.config in the root and the assemblies (dll files) in the site's bin folder.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #5 (permalink)  
Old October 4th, 2015, 03:48 PM
Authorized User
Points: 91, Level: 1
Points: 91, Level: 1 Points: 91, Level: 1 Points: 91, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2015
Location: rural Minnesota
Posts: 19
Thanks: 6
Thanked 0 Times in 0 Posts
Default

I was wrong about creating the EF framework directly on the web server. (Too many people, too many desktops, and too many rookies - including me. Your book is really great, but there are some things that need to be learned the hard way.)

I developed the site on a desktop and published it to the server.
On my desktop:
<packages>
<package id="EntityFramework" version="5.0.0" targetFramework="net45" />
</packages>

EntityFramework.dll > Version > 1[Neutral]

Now, how do I find out what the version is on the server? Is that something I can do myself, or is that a question that I need to ask of the administrator?
Reply With Quote
  #6 (permalink)  
Old October 4th, 2015, 04:05 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Just download the EntityFramework.dll from the server and look at its Properties in Windows Explorer. EF is "bin deployable" which means you can just upload your version to the site's bin folder.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #7 (permalink)  
Old October 5th, 2015, 11:27 AM
Authorized User
Points: 91, Level: 1
Points: 91, Level: 1 Points: 91, Level: 1 Points: 91, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2015
Location: rural Minnesota
Posts: 19
Thanks: 6
Thanked 0 Times in 0 Posts
Default

I need clarification on something. On your original reply to my original post, you mentioned that the server might be using a different version of EF. Does that mean that there is EF code on the server, probably in the .NET Framework, that does something with the EF code in my ASP app before it's sent to the browser?
If yes, that could explain the problem, although I don't know how to fix it - it may take a discussion with the web server administrator. All files in the server folder of my asp app are exactly the same as the files on my desktop since I ftp all files from my desktop to the server. The one exception is the data source values in the web.config files, but those values on the server are the same for the SQL connection string and for the entity connection string, and the SQL stuff all works.
As I'm thinking about this... does the Build > Publish Website do some actual processing so that simply using ftp to transfer files won't work with EF even though it works with SQL connects?
Thank you for all your help! I will certainly be a lot smarter when I finally get this thing to work.
Reply With Quote
  #8 (permalink)  
Old October 6th, 2015, 03:14 AM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
Does that mean that there is EF code on the server, probably in the .NET Framework, that does something with the EF code in my ASP app before it's sent to the browser?
It depends. For older versions, up to 4.0, EF was part of the framework.

For newer versions, you can deploy EF in your own bin folder so you don't depend on the EF version on the server. In this case I was referring to the F version in your Bin folder on the server as you said you built the model direclty on the server which could have meant it was using an older or newer version of EF.

Hard to answer the other questions as you're still not providing enough information such as the actual compilation error you're getting.

Quote:
As I'm thinking about this... does the Build > Publish Website do some actual processing so that simply using ftp to transfer files won't work with EF even though it works with SQL connects?
No, it shouldn't affect how EF works. Depending on how you deploy, your files may be precompiled but EF should just continue to work.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
Grodnik (October 7th, 2015)
  #9 (permalink)  
Old October 7th, 2015, 01:09 PM
Authorized User
Points: 91, Level: 1
Points: 91, Level: 1 Points: 91, Level: 1 Points: 91, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2015
Location: rural Minnesota
Posts: 19
Thanks: 6
Thanked 0 Times in 0 Posts
Smile

Thanks, Imar, for all your help. It turns out that there was a typo in the web config entities code when I changed the connect string for the server. There was an extra ; I must have looked at that a million times - well almost. I really appreciate all the time that you took to help solve the problem! Now, I hope you don't hear from me for a while.
Reply With Quote
  #10 (permalink)  
Old October 8th, 2015, 04:55 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Great, glad to hear you resolved the issue.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoMapper exception while using MVC with EF shazia1 BOOK: Professional ASP.NET MVC 4 0 September 9th, 2015 03:35 AM
EF Repository hpcsc BOOK: Patterns, Principles and Practices of Domain-Driven Design 2 August 26th, 2015 03:26 AM
Scafolding for non-EF? RKevinBurton BOOK: Professional ASP.NET MVC 4 0 March 24th, 2015 09:21 AM
connectionString using EF nanonerd ASP.NET 4 General Discussion 6 July 19th, 2012 01:28 PM
Generic Question and EF vbboyd BOOK: Beginning ASP.NET 4 : in C# and VB 4 May 19th, 2011 04:14 PM



All times are GMT -4. The time now is 11:40 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.