When using EF Code First, It appears WCF RIA Services Wizard (that runs when adding a new DomainService) in VS 2012 does not recognize the DbContexts defined in the project (it only recognizes the ObjectContext).
This means that when Adding a New Item in VS2012 and choosing Add DomainServiceClass, the wizard is not able to detect available context classes * combo list is empty *
Please see the attached image
Any idea what could be happening here?
Thanks,
-Sumit
This is a known issue with Visual Studio 2012, WCF RIA Services and Entity Framework, cause the Wizard to create new Domain Services doesn´t know the DbContext types.
The simple solution is to continue using Visual Studio 2010 to create Entity Models. Although using RIAServices.EntityFramework NuGet package won´t work, cause it doesn´t support current Versions of Entity Framework.
Another solution is to change the type of your Context from DbContext to ObjectContext.
Theres also a KB article for that specific scenario.
Update:
An update to WCF Ria Services was released to support EF 5 and the usage of DbContext. More information can be found here.
I believe that the wizard don't find your class due to the fact that WCF ria is older than EF 5. Try to redirect the assembly binding to
<runtime>
<legacyUnhandledExceptionPolicy enabled="1" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
...
let us know if it works
This is now possible with the 4.2 release of WCF RIA Services.
If you create a WCF RIA project and get prompted to select a Windows Phone version, this is a reported issue you need remove Windows Phone 8.0 & 7.1 SDK.
If then you get an error to do with project templates perform a repair on WCF RIA 1.0 SP2 which you should have already installed.
Related
I have an Website that use Entity Framework and SQLServer.
WHen I trying to run my application on Azure I get the following error:
Unable to determine the provider name for provider factory of type 'system.data.sqlclient.sqlclientfactory'. make sure that the ado.net provider is installed or registered in the application config.
On premises everything works fine.
I have finally discovered that the error was caused by this configuration section (that now I don't use anymore):
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, mysql.data" />
</DbProviderFactories>
</system.data>
I have removed it and now it worked correctly.
For future readers, this same error can also be seen when using Visual Studio 2017 v.15.7. I spent days browsing the web for solutions, and stubled upon this GitHub post mentioning a bug in EF Tooling. An update to v.15.8 as mentioned in the post solved the problem for me.
I have an ASP.NET MVC application that uses Entity Framework 5.0 and Code First.
I have published my website using Visual Studio 2012 to Azure Website. Everything seems to work except that the seed data is not inserted into SQL Azure; the website works, the database is built, but the seed data is not inserted. When I run this on my local machine, everything works correctly.
Based on examples that I have seen, when publishing from Visual Studio 2012 there is an option called “Execute Code First Migration” (see image below).
But when I try to publish my website the option “Execute Code First Migration” is not available.
I believe this may have something to do with how my solution is configured. I have 3 projects that makes up my application.
Website – This is an ASP.NET MVC project. It does have a reference Entity Framework, but all data access code (DBContext) is in the Data project
Domain – This is a class library. It does not have a reference to Entity Framework
Data – This project has reference to Entity Framework. I have a Configuration class that inherits from DbMigrationsConfiguration. In
this Configuration class I override the Seed method.
Again this all works on my local pc. For the most part everything works on Azure; the web site works, the database get built, but the seed data is not inserted.
For my scenario, are there any recommendations how to get the seed data to insert into SQL Azure when I do a publish from Visual Studio 2012?
You will need to manually edit your pubxml file (Properties/PublishingProfiles/YourName.pubxml) to make the check box appear. I have a blog post describing the situation and solution here: http://www.dominicstpierre.net/2012/11/enable-code-first-migrations-check-box.html
This part need to be manually changed
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="Namespace.Models.YourDBClass" Order="1" Enabled="True">
<Destination Path="your-connection-string-goes-here" />
<Object Type="DbCodeFirst">
<Source Path="DBMigration" DbContext="Namespace.Models.YourDBClass, AssamblyName" MigrationConfiguration="Namespace.Migrations.Configuration, Assambly" Origin="Convention" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
Change Namespace.Models.YourDBClass by your class that inherits DbContext, change Namespace.Migratins.Configuration to fit your migration configuration namespace and Assambly with your Assambly name.
Save and open the publish wizard you will have that check box.
We are developing a windows application on .NET 4, it uses SQLite database with .NET wrapper System.Data.SQLite and Entity Framework. On deployment machine it requires .NET 4 Client Profile.
The latest official release (1.0.66) of SQLite wraper is 2 years old. This version works with .NET 2.0 — 3.5, it's mean that we should force users to install 2 versions of .NET. Also it does not supports foreign keys.
There is also unofficial release 1.0.77 which supports foreign keys, however, support of ORM (.NET Entity Framework) is broken in this version (It raises System.Data.ProviderIncompatibleException).
I can see three ways to fix this issue:
Abandon the use of this wrapper and look for other options. What would you suggest?
Abandon the use of Entity Framework. This option is undesirable because it is old-school way and also require us to rewrite a lot and write more code and increate the likelihood of bugs.
Try to fix an issue with 1.0.77, but I have no idea how long it can take. What would you do in this situation? What other wrappers we should look at?
Finally, I understand how to let 1.0.77 System.Data.SQLite assembly to work with Entity Framework and without placing assembly to the GAC.
My first tries to connect SQLite 1.0.77 resulted in:
System.Data.ProviderIncompatibleException: A null was returned after calling the 'GetService' method on a store provider instance of type 'System.Data.SQLite.SQLiteFactory'. The store provider might not be functioning correctly.
Code analysis showed to me that main assembly System.Data.SQLite.dll can't find System.Data.SQLite.Linq.dll. The second assembly has been referenced in project and existed in output bin folder. But the error didn't disappeared.
Reflector showed that System.Data.SQLite.Linq.dll has no public classes. So it will never load automatically to app domain because there is no code referencing it. So it must be only in GAC for correct working.
But nothing can deny us to load it manually to app domain! For example, at application start:
Assembly.Load("System.Data.SQLite.Linq");
And that's it!
Also, don't forget about adding this lines to your application config:
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider" invariant="System.Data.SQLite"
description=".Net Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.77.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139"/>
</DbProviderFactories>
</system.data>
Hope my expierence will be usefull.
I notice the latest alpha of SolrNet supports Autofac integration.
This wiki page discusses how to integrate with the existing containers (StructureMap, Windsor, etc) but I couldn't find any examples on how to integrate with Autofac.
Since we're using Autofac 2.5.2, I've put in an assembly redirect from the old version that SolrNet wants:
<runtime>
<!-- SolrNet wants to use an old version of Autofac -->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da"/>
<bindingRedirect oldVersion="2.2.4.900" newVersion="2.5.2.830"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Which works ok. Now onto the actual registration, I've tried this:
builder.Register(c => new AutofacContrib.SolrNet.SolrNetModule("http://localhost:8983/solr/"));
Where builder is my Autofac ContainerBuilder.
But I can't figure out how to let SolrNet know I want results mapped to Dictionary<string, Object>.
Any examples of Autofac integration with SolrNet? As code is preferrable, although it would be good to see the XML config version, as well.
PS. I did notice the latest changes.txt on the SolrNet wiki mention an upgrade to Autofac 2.5 so my assembly binding can hopefully go away soon.
Thanks.
This wiki page discusses how to integrate with the existing containers (StructureMap, Windsor, etc) but I couldn't find any examples on how to integrate with Autofac.
It's normal for alpha releases to be poorly documented. Please consider sending a patch for the docs if you're using this feature.
Since we're using Autofac 2.5.2, I've put in an assembly redirect from the old version that SolrNet wants:
This has been upgraded to 2.5.2.830 in master branch, you might want to use that. You can get binaries from the build server.
But I can't figure out how to let SolrNet know I want results mapped to Dictionary<string, Object>.
This isn't implemented yet for the Autofac module. Please consider forking the repository and implementing it. However, using Dictionary<string, Object> as document type should be a last resort only. Whenever possible you should prefer to map fields to properly typed properties in a class.
Any examples of Autofac integration with SolrNet? As code is preferrable, although it would be good to see the XML config version, as well.
See the tests.
PS. I did notice the latest changes.txt on the SolrNet wiki mention an upgrade to Autofac 2.5 so my assembly binding can hopefully go away soon.
Again, I recommend using a recent built from the master branch.
I have a problem with an ASP.NET MVC site.
These are the details:
ASP.NET MVC 2
ASP.NET 4 integrated pipeline
IIS 7.5 on Windows Web Server 2008 R2
Whenever I make a request for the app I get the "HTTP Error 404.0 - Not Found"-error and the detailed error information shows it is the static file handler that reports the error:
Module: IIS Web Core
Notification: MapRequestHandler
Handler: StaticFile
Error Code: 0x80070002
meaning that the request never entered the MVC stack.
I should note that the IIS already serves a ASP.NET MVC 3 on the same app pool and a MVC 2 on a ASP.ENT 2 app pool. So it's the combo ASP.NET 2 on the ASP.NET 4 app pool that are giving me headaches.
Basically I want to upgrade the app from ASP.NET MVC 2 on a ASP.NET 2.0 app pool to a ASP.NET MVC 2 on a ASP.NET 4.0 app pool.
So any ideas?
I see you fixed your issue, but for anyone googling:
I had this issue and in my case I just needed to register ASP.NET 4 with IIS. I was deleting and re-adding webs to fix other issues and simply forgot to do that. The command that worked for me was:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -i
Your own .net version may be different, especially if you are in the future, so the above path may not be exactly right.
I had the same problem when I installed IIS after installing Visual Studio, etc.
I was able to fix the problem by changing my Web.config file, adding the runAllManagedModulesForAllRequests="true" to the <modules> tag:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
...
</modules>
</system.webServer>
(More details/copied from here: http://www.west-wind.com/weblog/posts/2011/Mar/27/ASPNET-Routing-not-working-on-IIS-70)
Chris' answer got me to check whether the app pool was actually configured for .net 4. Sure enough, this server defaults to creating 32-bit .net 2 pools in classic mode.
Ensure that your app is using 4.0 and you'll probably want Integrated pipeline for all new development. 32/64 is mainly up to your dependencies. The default is leaving "allow 32 bit allocations" set to false.
In my case, a similar error was thrown because StaticFile Handler was disabled / not working properly. I eventually fixed it by removing the handler and re-adding it through the web.config. Also, in case of a 403.3 error, change the RequireAccess-property value from "Write" to "Read"
<configuration>
<system.webServer>
<handlers>
<remove name="StaticFile"
<add
name="StaticFile"
path="*" verb="*"
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
resourceType="Either"
requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>
So I found the error. There was a left over default document in the root, which isn't necessary for apps using the integrated pipeline. Also some changes to Global.ascx and route registration was neessary, but after that it worked.