Error using DbContextBaseClass in EntityFramework Reverse POCO Code First Generator - entity-framework

Error when using a DbContextBaseClass that does not implement a constructor,is there any documentation,Example or Demo on how to use DbContextBaseClass in the template setting to make ASP.NET Identity works ?
i used the guide in the comment:
DbContextBaseClass = "DbContext"; // Specify what the base class is for your DbContext. For ASP.NET Identity use "IdentityDbContext<ApplicationUser>"
but i always end up with two a compile errors :
1- The type or namespace name 'IdentityDbContext' could not be found
(are you missing a using directive or an assembly reference?)
2- The type or namespace name 'ApplicationUser' could not be found
(are you missing a using directive or an assembly reference?)
Apparently someone else is having the same issue :
Link Here

As the ASP.NET identity already includes all the entity framework code within your project, there is no need to reverse engineer it.
I would instead use the Reverse POCO generator to reverse engineer all your own tables, and add a filter to exclude the ASP.NET identity tables alone.
TableFilterExclude = new Regex("^__MigrationHistory$|^AspNetRoles$|^AspNetUserClaims$|^AspNetUserLogins$|^AspNetUserRoles$|^AspNetUsers$");

Related

DNN deprecated methods on upgrade

I'm trying to upgrade my old DNN website to DNN version 9.8.0. The problem is that I have one custom module installed and it is using deprecated methods that I'm resolving using the table of deprecated methods and I ran on one issue that I don't really understand what to do with it:
retRole = DotNetNuke.Security.Roles.RoleProvider.Instance().GetRole(module.PortalId, roleid);
Error is: 'DotNetNuke.Security.Roles.RoleProvider' does not contain a definition for 'GetRole' and no extension method 'GetRole' accepting a first argument of type 'DotNetNuke.Security.Roles.RoleProvider' could be found (are you missing a using directive or an assembly reference?)
In the table of deprecated method, for public virtual RoleInfo GetRole(int portalId, int roleId) it says: Deprecated in DotNetNuke 6.2. Roles are cached in the business layer
Does anyone knows what it means and how to resolve this?
Instead of using the RoleProvider, I would use the RoleController:
retRole = DotNetNuke.Security.Roles.RoleController.Instance().GetRoleById(module.PortalId, roleid);
In DNN9.8, RoleProvider doesn't have the method GetRole anymore.

EF6.Utility.CS.ttinclude: ArgumentNotNull does not exist

I just upgraded to EF6 from EF5 and I encounter this error in a custom T4 that connects to the DB using a DbContext from a different assembly.
File: EF6.Utility.CS.ttinclude
Compiling transformation: The name 'ArgumentNotNull' does not exist in the current context
What I've done is replacing EF.Utility.CS.ttinclude with EF6.Utility.CS.ttinclude, which solved another error about DbSet and DbContext not being found.
The T4 is very simple, like this one:
using(var context = new EntityContext)
return context.Entities.Where(x => 1==1);
Except for the EF include I only reference my own assemblies. The freshly-added Context is generating just fine (in another project).
What on earth could be wrong?
EF6.Utility.CS.ttinclude reference some static functions that are defined in the main template.tt so you need to have them in your template too.
Example:
Entity.tt defines ArgumentNotNull(T arg, string name) which is used in the EF6.Utility.CS.ttinclude (it's not the way we are used to have)
See the bottom of generated template from EF6 designer to see this missing functions
One way to solve this is moving almost all the code to a .cs file and then use that file in the T4 template. Then remove the EF ttinclude from the T4 template.
Works and is easy better praxis to follow.

Entity framework Beta 3 database, does not give DeleteOnSubmit

I do not get context DeleteOnSubmit!! All other functions like Add, Count, etc… work fine! Due to this, I cannot delete the record.
Error 1 'System.Data.Entity.DbSet<mvc2db.Company_Dext>' does not contain a
definition for 'DeleteOnSubmit' and no extension method 'DeleteOnSubmit' accepting
a first argument of type 'System.Data.Entity.DbSet<mvc2db.Company_Dext>' could be
found (are you missing a using directive or an assembly reference?)
I am using Visual Studio 2012 Premium edition
thanks
In Entity Framework 5, there is no DeleteOnsubmit instead there is .Remove(record entity).

Using Code First and Database First Entity Framework with Devart

I have one website that uses EF 4.4 (.NET 4.0 version of EF 5.0) that uses Code First against an existing database. I use the Devart oracle data provider which requires a workaround because of casing issues with the model type.
It makes the Devart provider recognize lowercase datatypes to interpret the schema. (Or something along those lines)
This works properly, until the control within this website, built on EF 4.1 Database First (Also against an existing database) tries to load. The Devart provider seems to be shared across the websites, and it results in errors about the provider not being able to recognize the datatypes (correctly) in all caps, because of the previous workaround to make it work in Code First.
Is there a workaround for this, or do I have to convert the Database First approach to Code First?
Edit: Here is the related workaround code. I seem to have lost the forum post I got it from. I believe it was on the Devart forums:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
var config = Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance;
config.Workarounds.ColumnTypeCasingConventionCompatibility = true;
... initialization code here ...
base.OnModelCreating(modelBuilder);
}
And the related error is this:
System.Data.MetadataException: Schema specified is not valid. Errors:
Model.ssdl(205,6) : error 0040: The Type CHAR is not qualified with a namespace or alias. Only primitive types can be used without qualification.
Model.ssdl(206,6) : error 0040: The Type VARCHAR2 is not qualified with a namespace or alias. Only primitive types can be used without qualification.
There are a bunch more, but they're all the same error with different lines and data types.
The Devart provider seems to be shared across the websites
After the ColumnTypeCasingConventionCompatibility option is set, it determines the behaviour of the current application domain (web site). The process (web server) may run several application domains with different values of ColumnTypeCasingConventionCompatibility.
The value of ColumnTypeCasingConventionCompatibility for the particular application domain depends on the Fluent Mapping property of the DbContext template used for the model in web site. Fluent Mapping=true must be used with ColumnTypeCasingConventionCompatibility=true, and vice versa: Fluent Mapping=false must be used with ColumnTypeCasingConventionCompatibility=false.
You can set ColumnTypeCasingConventionCompatibility for a web site in the following alternative ways:
a) in your code before the first usage of the context (e.g., in a static constructor of the context or in the Main method of your program, etc)
b) in *.config. For example:
<configuration>
<configSections>
<section name="Devart.Data.Oracle.Entity"
type="Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfigurationSection,
Devart.Data.Oracle.Entity, Version=7.5.179.0, Culture=neutral,
PublicKeyToken=09af7300eec23701" />
</configSections>
<Devart.Data.Oracle.Entity xmlns="http://devart.com/schemas/Devart.Data.Oracle.Entity/1.0">
<CodeFirstOptions ColumnTypeCasingConventionCompatibility="true"/>
</Devart.Data.Oracle.Entity>
</configuration>

Doctrine 2.1 abstract entity, validation using annotations

My name is Denis and I really need your help or advice or anything :)
I am developing my project in Zend Framework 1.11 and am using Doctrine 2.1.
I have successfully integrated Doctrine in my ZF project and everything works. I also integrated Gedmo extensions and some my custom extensions.
The problem is with validation. I want to have validation of doctrine entities by using annotations. Because I sometimes need to validate my entities sometimes don't, I want that sort of validation, for example:
$user = new Entity\User; $user->setName('user'); $user->validate();
I don't want to change doctrine generated entities at all, so I won't change setters or use doctrine events for this.#HasLifecycleCallbacks.
I run into example at http://www.spiffyjr.me/2011/07/15/more-doctrine-2-and-zend-framework-integration-goodies/.
I downloaded code but didn't managed to put it in work. I followed instructions from that page, made my entities extend AbstractEntity, but when try to use for example isValid() i recieve following error:
[Semantical Error] The annotation "#Column" in property Bild\Entity\TestTest::$id was never imported. Did you maybe forget to add a "use" statement for this annotation?
I use doctrine annotations without #ORM\, just #, (for example #Column, not #ORM\Column). I even tried to add ORM but no luck it continues to throw errors.
I can recieve metadata for my entity, get field mappings and associating mappings, but when I try to getPropertyAnnotation
// validator annotations
$vAnnotations = self::_getPropertyAnnotation($property, self::ZENDVALIDATION);
var_dump($vAnnotations);die;
I recieve mentioned semantic error.
I tracked the errors down to Doctrine\Common\Annotations\AnnotationReader::getPropertyAnnotations($property); not returning annotations but throwing errors.
What do you think it can be?
It seems like I am not doing something properly but can't figure out what.
So, I need to make abstract entity, make my entities extend it, and make functions to validate my entities by using annotations.
So please, help me with this, if you can. I really need for my project but couldn't find a solution.
Thanks in advance.
Best regards.
The problem is caused by the configuration of the annotation reader. I went through the same problems while integrating the Symfony2 validator service for my Doctrine2 models in ZF1, more on the blog post here http://ssmusoke.wordpress.com/2012/03/04/doctrine-2-day-2-model-validation-using-symfony-validator-service-in-zend-framework/