SQL Linked server – Change of password

TODO confirm this works then mark as Solved

A linked server using VFPOLEDB has worked for sometime here. Then the server related user password was changed and it all stopped working. Perhaps consider following page

http://msdn.microsoft.com/en-us/library/ms175537.aspx

“Linked server login mappings can be added by using sp_addlinkedsrvlogin and removed by using sp_droplinkedsrvlogin. A linked server login mapping establishes a remote login and remote password for a specified linked server and local login. When SQL Server connects to a linked server to execute a distributed query or a stored procedure, SQL Server looks for any login mappings for the current login that is executing the query or the procedure. If there is a login mapping, SQL Server sends the corresponding remote login and password when it connects to the linked server.”

Entity Framework: WinForms databinding in EF4.1 – DBSet

Solved

Dim context As New SOPEntities
System.Data.Entity.DbExtensions.Load(context.Employees.Where(Function(f) f.Current = True).OrderBy(Function(g) g.FullName))
EmployeeBindingSource.DataSource = context.Employees.Local
ListBox1.DataSource = System.Data.Entity.DbExtensions.Tobindinglist(context.Employees.Local)
ListBox1.DisplayMember = “FullName”

Problem

‘local’ is not a member of ‘System.Data.Objects.ObjectSet(Of <entityname>)’

See http://wp.me/p17IS4-ih

 

Solved

Open the <Name>Model.edmx > Right click > Add code generation item…

Choose ADO.Net DbContext Generator. This has affect of changing the .edmx file Code Generation Strategy to “None” and creates a text template model and .Local now works.

Discussion

Uses EF4.1 EntityFramework.dll
Database first, then add code generation item to get T4 simpler classes and DBSet inherits DBContext
Initially could not work out how to get the Load method. See above for solution.
There is no MSDN VB.Net sample yet. The C# is more like context.Employees.Local.ToBindingList. So it took me a while to work out the syntax above.

Unsolved:
Also the FullName is now a computed column in the database. Was unable to work out how to do this in EF. It may come in the future as a “Model Defined Function”. Do not think this is a Scalar or Complex Type which is something else.
Unsolved:
For BindingSource to support complex filter it needs to support IBindingListView. Typically EF does not.

Links

Binding Objects to Controls
http://msdn.microsoft.com/en-us/library/gg197521(v=VS.103).aspx

Following is in C#
http://msdn.microsoft.com/en-us/library/gg197523(v=VS.103).aspx

Entity Framework “Update Model from Database” generates unexpected self-reference associations / navigation properties

EF4.1 Entity Framework “Update Model from Database” generates unexpected self-reference associations / navigation properties

Check in SQL server on the table design, if a relationship started to be formed, but was not completed then it may be left on the table. Removing this unnecessary relationship and then using “Update Model from Database” will remove these extra associations

Entity Framework: Error 111: Properties referred by the Principal Role…

The following error message may contain entity name or other project specific text

Error 111: Properties referred by the Principal Role must be exactly identical to the key of the EntityType referred to by the Principal Role in the relationship constraint for Relationship . Make sure all the key properties are specified in the Principal Role.

Solution upgarde to EF4.1 or higher.

 

Reference in the manifest does not match the identity of the downloaded assembly

SOLVED

Click-once does not install presenting error message:
“Reference in the manifest does not match the identity of the downloaded assembly …exe”

This could be if the referenced project is an executable, you may find that if you change the reference from a project reference to the executable file then try this may work.
Alternatively and if possible change the referenced project to  Class Library.

UPDATE 17/02/2012
Today I have extracted a Windows Forms from a main project into a smaller executable and referenced it from the main project.
I did a few things including above and then also it did not work until I had published the smaller project and it gained a certificate. Think the error was a validation error.

Entity Connection String at run-time

 

Following is useful

Public Shared Function GetRunTimeEntityConnectionString(EntityConnectionStringName As String) As String
Dim currentConString = Configuration.ConfigurationManager.ConnectionStrings(EntityConnectionStringName).ConnectionString
Dim builder As New EntityClient.EntityConnectionStringBuilder(currentConString)
builder.ProviderConnectionString = <“NewConString”>
‘builder.Metadata = “res://*/LookupModel.csdl|res://*/LookupModel.ssdl|res://*/LookupModel.msl”
‘builder.Provider = “System.Data.SqlClient”
Return builder.ConnectionString
End Function

Usage
Dim EntityConnectionString = RuntimeConnectionString.GetRunTimeEntityConnectionString(<EntityConStringName>)
context = New <Namespace>.EntityModel.<EntityName>Entities(EntityConnectionString)

If trying to change actual SharedApp.config as follows then currently get an error.
Configuration.ConfigurationManager.ConnectionStrings(<“Name of Entity ConString”>).ConnectionString = RunTimeEntityConnectionString
Error:
system.configuration.configurationerrorsexception the configuration is read only

There are suggested methods for solving this online

Error on Project Settings “An error occurred while reading the app.config file” when using configSource

Error: on opening Project > Settings
“An error occurred while reading the app.config file. The file might be corrupted or contain invalid XML”
However all functionality works

Occurs when using
<connectionStrings configSource=SharedApp.config></connectionStrings>

Solution: Unknown

How to use “external” configuration files e.g. SharedApp.config with a test project?

Error:
Test method TestProjectBusiness.dsBusinessHelperTest.FillAdviceNoteTest threw exception:
System.Configuration.ConfigurationErrorsException: Unable to open configSource file ‘SharedApp.config’. (…Visual Studio 2010\Projects\…\TestResults\…\Out\TestProject.DLL.config line 8)

Solution at:
http://stackoverflow.com/questions/152866/how-can-you-use-external-configuration-files-i-e-with-configsource-with-an-m

Quote
“If you edit the test run configuration (by double clicking the .testrunconfig file that gets put into the ‘Solution Items’ solution folder when you add a new unit test), you get a test run configuration dialog. There’s a section there called ‘Deployment’ where you can specifiy files or whole folders from anywhere in the solution that can be copied out with the compiled assemblies at run time to the correct folder.

In this way, I can now actually just define most of my configuration in one set of external .config files and have them automatically copied out at the run of each test.”

My Notes:
This works. You may have to close and re-open the test run – test list editor .vsmdi for the appropriate test-settings to take affect.

Some of the properties associated with the solution could not be read

Visual Studio when opening a solution.
“One or more projects were not loaded correctly”
“Some of the properties associated with the solution could not be read”

Following did not work really, but does discuss the corrupt solution file, which may have a different number of projects to those attached to this solution.
http://blogs.msdn.com/b/rjohri/archive/2010/03/11/some-of-the-properties-associated-with-the-solution-could-not-be-read.aspx

Alternative is to create a new solution and add the projects to it.

Also am finding that Windows 7 machine, moving to XP machine, is making XP machine files read-only. This may be part of the problem.

“Changes to 64-bit applications is not allowed” when attempting to edit code at run-time

If this is holding you back then try:
> Project Properties > Compile > Advanced Compile Options > Target CPU: change to x86