Giter Site home page Giter Site logo

Comments (7)

mrahhal avatar mrahhal commented on August 26, 2024

Hello, you can't use DateTime instead as that property is already defined using DateTimeOffset. I'm not entirely sure but I think this can be solved by overriding OnModelCreating in your DbContext and manually setting up that property to use a different data type.

from mr.aspnet.identity.entityframework6.

bastienchauvin avatar bastienchauvin commented on August 26, 2024

After hours of searching I have just one idea :

modelBuilder.Properties<DateTimeOffset>()
    .Configure(c => c.HasColumnType("datetime2").HasPrecision(0));

But I have always an error. I can't mark my property with [NotMapped] too.

Please, do you have a solution?

from mr.aspnet.identity.entityframework6.

mrahhal avatar mrahhal commented on August 26, 2024

What's the error?

from mr.aspnet.identity.entityframework6.

bastienchauvin avatar bastienchauvin commented on August 26, 2024
System.InvalidOperationException: The sequence contains no matching element.
   à System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
   à System.Data.Entity.Utilities.DbProviderManifestExtensions.GetStoreTypeFromName(DbProviderManifest providerManifest, String name)
   à System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.ConfigureColumn(EdmProperty column, EntityType table, DbProviderManifest providerManifest)
   à System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.Configure(EdmProperty column, EntityType table, DbProviderManifest providerManifest, Boolean allowOverride, Boolean fillFromExistingConfiguration)
   à System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.<>c__DisplayClass4.<Configure>b__3(Tuple`2 pm)
   à System.Data.Entity.Utilities.IEnumerableExtensions.Each[T](IEnumerable`1 ts, Action`1 action)
   à System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.Configure(IEnumerable`1 propertyMappings, DbProviderManifest providerManifest, Boolean allowOverride, Boolean fillFromExistingConfiguration)
   à System.Data.Entity.ModelConfiguration.Configuration.Types.StructuralTypeConfiguration.ConfigurePropertyMappings(IList`1 propertyMappings, DbProviderManifest providerManifest, Boolean allowOverride)
   à System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.ConfigurePropertyMappings(DbDatabaseMapping databaseMapping, EntityType entityType, DbProviderManifest providerManifest, Boolean allowOverride)
   à System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.Configure(EntityType entityType, DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
   à System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntityTypes(DbDatabaseMapping databaseMapping, ICollection`1 entitySets, DbProviderManifest providerManifest)
   à System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
   à System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
   à System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
   à System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
   à System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
   à System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   à System.Data.Entity.Internal.LazyInternalContext.get_ModelBeingInitialized()
   à System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(DbContext context, XmlWriter writer)
   à System.Data.Entity.Utilities.DbContextExtensions.<>c__DisplayClass1.<GetModel>b__0(XmlWriter w)
   à System.Data.Entity.Utilities.DbContextExtensions.GetModel(Action`1 writeXml)
   à System.Data.Entity.Utilities.DbContextExtensions.GetModel(DbContext context)
   à System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext, DatabaseExistenceState existenceState, Boolean calledByCreateDatabase)
   à System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration)
   à System.Data.Entity.Migrations.Design.MigrationScaffolder..ctor(DbMigrationsConfiguration migrationsConfiguration)
   à Migrator.EF6.Program.Executor.AddMigration(String name)
   à Migrator.EF6.Program.<>c__DisplayClass0_4.<Main>b__15()
   à Microsoft.Dnx.Runtime.Common.CommandLine.CommandLineApplication.Execute(String[] args)
   à Migrator.EF6.Program.Main(String[] args)
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
   à Microsoft.Dnx.ApplicationHost.Program.<>c__DisplayClass3_0.<ExecuteMain>b__0()
   à System.Threading.Tasks.Task`1.InnerInvoke()
   à System.Threading.Tasks.Task.Execute()

from mr.aspnet.identity.entityframework6.

bastienchauvin avatar bastienchauvin commented on August 26, 2024

If I add "datetime" in palce of "datetime2" i have an error of MySql convertion on the Migration Add.
You don't have any way to modify this mapping or change the property type ?
A magic ovveride of this type :( ?

Thanks a lot

from mr.aspnet.identity.entityframework6.

mrahhal avatar mrahhal commented on August 26, 2024

I'm not sure why this is not working when you manually tell it to use datetime2. You can try to fork this and simply change the LockoutEnd property's type to DateTime instead as a last resort.

from mr.aspnet.identity.entityframework6.

mrahhal avatar mrahhal commented on August 26, 2024

I'm closing this, please reopen if you still have issues.

from mr.aspnet.identity.entityframework6.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.