With VS 2010 SP1 I created an ASP.NET MVC4 project from the "internet" template. I then created a connection string for SQL Server CE 4.0:
<add name="DefaultConnection"
connectionString="Data Source=|DataDirectory|MyDatabase.sdf;Password=123456"
providerName="System.Data.SqlServerCe" />
With the web application successfully debug-launched in cassini, I choose the "Register" user option. Immediately this causes the InitializeSimpleMembershipAttribute filter to execute. The filter crashes the site when it reaches this code:
Database.SetInitializer<UsersContext>(null);
using (var context = new UsersContext())
{
if (!context.Database.Exists())
{
// Create the SimpleMembership database without Entity Framework migration schema
((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
}
}
//This line never executes. It is meant to configure my custom user table.
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "Users", "ID", "UserName", true);
The Exists() check throws an ArgumentException stating:
Unable to find the requested .Net Framework Data Provider. It may not be installed.
Now I wanted to be sure that (1) there was nothing wrong with my connection string and (2) there was nothing wrong with my provider. To do that, I inserted a snippet of code before the Exists() check. The snippet used a new SqlCeEngine to create the database, and Dapper calls to setup user tables. That code worked just fine, just before exploding on the Exists() check again.
I then considered that EF might need some additional setup help. I tried replacing the EF defaultConnectionFactory in my web.config:
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
Still the exception I received did not change.
I'm now wondering if EF needs a "special" connection string to work with SQL Server CE. I will be checking here and here. But at first glance I'm not sure that is the issue.
Thoughts?
EF requires the providers to be installed.
Use one the connect to DB options to check. eg ADD Entity DAta Model to Project. Just to the providers available to it. Do you see your preferred connection Client ?
Seems Compact edition should work with some restrictions...
http://technet.microsoft.com/en-us/library/cc835494.aspx
So then I think its The "DEFAULT CONNECTION" issue
See the Context constructor. EF looks for a connection by that name unless you pass an alternative in.
try...
<connectionStrings>
<add name="MyContextName" connectionString="bla";App=EntityFramework"
providerName="System.Data.SqlServerCe.4.0" />
You need to install Sql Server Compact edition. You can download it from here.
Related
i need to call an old asmx web service (I have not control over)from a .net core web api
is it possible?
thanks
The way I was able to do it was fully update Visual Studio 2017, then get the latest WCF Connected Services extension from here:
https://marketplace.visualstudio.com/items?itemName=WCFCORETEAM.VisualStudioWCFConnectedService
After I did that, I was able to add and call the SOAP service like so.
Right click on Connected Services folder (should appear just below your project) and select Add Connected Service. Then select "Add a WCF web service". Put your asmx url into the URI field, set the name space and click Finish. You will now have the reference set.
An example of what my code does...
If you don't have an authorization header, you can ignore that part:
MySoapClient.EndpointConfiguration endpoint = new MySoapClient.EndpointConfiguration();
MySoapClient myService = new MySoapClient(endpoint, myURL);
AuthorizationSoapHeader MyAuthHeader = new AuthorizationSoapHeader();
MyAuthHeader.AppName = FDSServiceAppName;
MyAuthHeader.AppID = Guid.Parse(MyAppID);
Entry[] entries = MyService.GetUsers().Result;
The accepted answer is 100% correct, but there was one gotcha when trying to add an ASMX Web Service with VS WCF Connected Services that I encountered, but wasn't initially obvious to me.
In my case the web service that I was trying to connect to had disabled the WSDL in the Web.config. I had to remove or comment out the following in the Web.config to allow the metadata to be imported and code scaffolded successfully.
<webServices>
<protocols>
<!-- <remove name="Documentation" /> -->
</protocols>
</webServices>
Once <remove name="Documentation" /> is removed or commented out like the example above, the ASMX service will be able to be added to your project.
I have looked at all the docs for Thinktecture Identity server v3 and have not been able to figure out how to get started using ASP.NET identity.
Can someone please explain at a high level step by step from step 1 (i.e. cloning the git repo) to it's final state which is up and running with the Identity Manager as well. Essentially I just need to know how to set this up.
The videos I see on Vimeo seem out of date (and I may be wrong because I am new to this) because now there are several repositories and in the videos I think I saw the asp.net identity user service in the same solution in core.
I am trying to prototype this for my employer (AngularJS, Identity Server, OAuth 2.0, resource owner vs implicit flow, ) and am hoping to get this working as soon as possible.
Many thanks in advance!
Andrew
Have you checked Thinktecture.IdentityManager.AspNetIdentity solution? There is example how to configure it (see Host project):
public void Configuration(IAppBuilder app)
{
var factory = new Thinktecture.IdentityManager.Host.AspNetIdentityIdentityManagerFactory("AspId");
app.UseIdentityManager(new IdentityManagerConfiguration()
{
IdentityManagerFactory = factory.Create
});
}
In order to add this functionality to the clean project you just have to add necessary packages
<package id="Thinktecture.IdentityServer.v3" version="1.0.0-beta1" targetFramework="net45" />
<package id="Thinktecture.IdentityServer.v3.AspNetIdentity" version="1.0.0-beta1" targetFramework="net45" />
and configure it in the Startup. It's not necessary to clone git repo and compile it...
I´ve searched the following links:
How to deploy Oracle with EF
Problems deploying Oracle with EF
And many other posts around regarding Oracle deployment.
Basically I have an C# simple test application to insert some rows into a database (this is a test application. The full application uses a lot of EF stuff):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;
using MzDbLib.DataAccessObject;
using MzDbLib.DatabaseContext;
using MzDbLib.DatabaseModel;
namespace TestDbConnection
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("This program will generate 10 logs into SYSTEMDATALOG table");
///
/// Do a loop of 10 logs generated
///
for (int i = 0; i < 10; i++)
{
string msg = "TEST GENERATED LOG NUMBER " + i.ToString();
Console.Write("Generating log " + i.ToString() + "...");
//
// Connect to database and to the log table
//
Entities dbContext = new Entities();
SYSTEMDATALOG logTable = new SYSTEMDATALOG();
logTable.DATETIME = DateTime.Now;
logTable.TYPE = "INFO";
logTable.SEVERITY = 0;
logTable.SOURCE = "TESTDBCONNECTION";
logTable.USER = "SYSTEM";
logTable.MESSAGE = msg;
dbContext.SYSTEMDATALOG.Add(logTable);
dbContext.SaveChanges();
Console.WriteLine("Done.");
}
Console.WriteLine ("Data generated at the database. Press a key to end test.");
Console.ReadKey();
//
// Application exit
//
Environment.Exit(0);
}
}
}
The dbContext and SYSTEMDATALOG classes were generated though EF model-first from an Oracle database. I´m using Visual Studio 2012 and ODAC 12.1.0.1.0 with Oracle Developer Tools 32-bit installed on development machine. All fresh install and working pretty fine when developing.
All runs fine in DEVELOPMENT, but neve in production.
I´m using in production WINDOWS SERVER 2012. I have tried the following approaches:
a) Install WS2012 from schatch and install ODAC 32-bit version 12.1.0.1.0 fresh from Oracle site. I did run install
with ODAC 4 version.
I got "The provider is not compatible with the version of Oracle client". After some tries and some hours lost, with different approaches, I decided to go to a new method - non-installating Oracle
b) I fresh installed WS2012 and did no ORacle installation. Copied the DLLs stated in the above links and now I´m getting "Unable to find the requested .NET data provider". I´ve copied all the available Oracle DLLs from DEV machine to the WS2012 EXE directory of my application and still getting that error.
My connection string (auto-generated by VS2012) is:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<connectionStrings>
<add name="Entities" connectionString="metadata=res://*/DatabaseModel.DatabaseModel.csdl|res://*/DatabaseModel.DatabaseModel.ssdl|res://*/DatabaseModel.DatabaseModel.msl;provider=Oracle.DataAccess.Client;provider connection string="data source=//ORACLESERVER1:1521/MEZAMES;password=xxx;persist security info=True;user id=MZMESDB"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
This string is being generated into 2 files: TestDbConnection.exe.config and TestDbConnection.vshost.exe.config (I´m copying the bin/Debug folder to the server).
So, I need help to deploy my app to the new server. Some questions:
a) Which DLL is needed to go with the application for ODAC 12.1.0.1 ? Does that changed from ODAC 11 ?
b) Is that last error regarding EF or Oracle ?
c) Why does VS generated 2 config files ?
d) Does "providerName="System.Data.EntityClient" is the cause of the error ? If so, what DLL should be copied together.
e) Is there any tool/way to know what´s missing or with incompatible version, avoiding copying and trying methods ?
f) Is something missing on the config file ?
Thanks all for any kind of help. This is making me crazy as I´m stuck on that since the beggining of the week...
I'm not sure about the installation options for ODAC in a server environment. I know you need the Transaction module only if you're using TransactionScope in your code.
The problem you're seeing from not being able to find the provider is because Oracle changed the provider name from Oracle.DataAccess.Client to Oracle.ManagedDataAccess.Client with the 12c bits.
You need to change this in both the connection strings and in the SSDL section of the EDMX file: you will go from
<edmx:StorageModels>
<Schema Namespace="Model.Store" Alias="Self" Provider="Oracle.DataAccess.Client" (...)
to
<edmx:StorageModels>
<Schema Namespace="Model.Store" Alias="Self" Provider="Oracle.ManagedDataAccess.Client" (...)
I just downloaded Umraco (via Web Platform Installer).
It takes me to this web page:
How can I just select 'integrated security'?
That connection string is set to a blank database that exists. I have added 'IIS AppPool\DefaultAppPool' and 'IIS APPPOOL\UmbracoTest' as database owner. The next screen is like this Database configuration is invalid for connection string Data Source=.;Integrated Security=True;Initial Catalog=UmbracoTest:
That connection string is fine, I've used '.' datasource elsewhere with no problems (SQL Express).
Is there any way to get useful error messages?
How can I get this working?
Thanks.
I just ran into the same issue during an Umbraco 6.1.5 installation. My issue was the providerName being empty as suggested, so when I added:
providerName="System.Data.SqlClient"
I was able to install and upgrade my Umbraco 6.1.3 database. My full connection string is:
<add name="umbracoDbDSN" connectionString="server=72.18.**.***,1533;database=mydatabase;user id=emma;password=******" providerName="System.Data.SqlClient" />
The connection string is wrong, trust me :)
Instead of DataSource=. try DataSource=.\sqlexpress
Also ensure that the initial catalog=UmbracoTest is actually the correct name of the database.
Finally, since you are using an Umbraco 6.x version, the log files will be at ~App_Data/Logs but in this case they will just tell you much the same as the install screen, that an SqlException has occurred.
Edit:
Looking at the Umbraco source, the error you see is raised by the following code:
if (_configured == false ||
(string.IsNullOrEmpty(_connectionString) ||
string.IsNullOrEmpty(ProviderName)))
{
return new Result
{
Message =
"Database configuration is invalid. Please check
that the entered database exists and that the provided
username and password has write access to the
database.",
Success = false,
Percentage = "10"
};
}
So my assumption is that you are missing the Provider from your connection string. In your web.config file your connection should look like this:
I had the same issue. I fixed it by adding the IIS_IUSRS user to the Umbraco site directory with "Modify" rights as the setup process is trying to write to the web.config with your connection string. Hope this helps.
Can someone please post a confirmed example using linq to retrieve and update a record in CRM Dynamics 2011.
Microsoft claims this is "unsupported" but I have a suspicion it is possible.
I use the "early bound" approach where you generate C# entity classes using the CrmSvcUtil.exe tool, but make sure you use the /codecustomization switch that you'll find in various examples. You'll need the latest version of the CRM 2011 SDK, and must run CrmSvcUtil.exe from the \bin folder of that (don't use the version that installs with CRM).
Your project will need to reference Microsoft.Xrm.Client, Microsoft.Xrm.Sdk and Microsoft.Crm.Sdk.Proxy plus a few others from the .Net framework (look at the build errors to see what you're missing, then add them until it builds).
Here is a basic code snippet that retrieves a Contact entity, updates one of its fields, then saves it back to CRM:
CrmDataContext dc = new CrmDataContext("Xrm");
Contact contact = (from c in dc.ContactSet
where ...whatever...
select c).FirstOrDefault();
contact.FirstName = "Jo";
dc.SaveChanges();
(Note that CrmDataContext is the name of my data context. You can set this name using one of the CrmSvcUtil command line switches).
You'll also need to add a few things to your web.config:
<configSections>
<section name="microsoft.xrm.client" type="Microsoft.Xrm.Client.Configuration.CrmSection, Microsoft.Xrm.Client" />
</configSections>
<connectionStrings>
<add name="Xrm" connectionString="Server=http://<your crm url>; Domain=<your domain>; Username=<a crm user id>; Password=<their password>" />
</connectionStrings>
<microsoft.xrm.client>
<contexts>
<add name="Xrm" type="" />
</contexts>
</microsoft.xrm.client>
This is assuming you are running CRM on your corporate network, so the account and domain specified in the connection string would be an AD account, who is set up as a CRM user with relevant permissions to retrieve and update entities.
This is a rough example of using the ODATA provider connected to the online provider
var serverConfig = GetServerConfig(sessionKey);
// Connect to the Organization service.
// The using statement ensures that the service proxy will be properly disposed.
using (var serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials))
{
// This statement is required to enable early-bound type support.
serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
using (var orgContext = new CrmServiceContext(serviceProxy))
{
return orgContext.AccountSet.Where(item => item.Id == id).Select().Single();
}
}
there's also a good example in the SDK:
CRM2011Sdk\sdk\samplecode\cs\wsdlbasedproxies\online