 |
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 3rd, 2015, 12:33 PM
|
Authorized User
|
|
Join Date: Aug 2015
Posts: 19
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
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.
|

October 4th, 2015, 07:40 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|

October 4th, 2015, 02:13 PM
|
Authorized User
|
|
Join Date: Aug 2015
Posts: 19
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
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.
|

October 4th, 2015, 02:40 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
>> 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
|

October 4th, 2015, 03:48 PM
|
Authorized User
|
|
Join Date: Aug 2015
Posts: 19
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
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?
|

October 4th, 2015, 04:05 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|

October 5th, 2015, 11:27 AM
|
Authorized User
|
|
Join Date: Aug 2015
Posts: 19
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
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.
|

October 6th, 2015, 03:14 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
The Following User Says Thank You to Imar For This Useful Post:
|
|

October 7th, 2015, 01:09 PM
|
Authorized User
|
|
Join Date: Aug 2015
Posts: 19
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
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.
|

October 8th, 2015, 04:55 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Great, glad to hear you resolved the issue.
Cheers,
Imar
|
|
 |
|