Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

: Schema specified is not valid. Errors: (0,0) : error 0040: The Type is not qualified with a namespace or alias. Only primitive types can be used without qualification #35

Open
MikelLuri opened this issue Feb 26, 2019 · 2 comments

Comments

@MikelLuri
Copy link

MikelLuri commented Feb 26, 2019

I've made a simple project to test ModelDefinedFunctions and I can't get it to work... I get an exception:

MetadataException: Schema specified is not valid. Errors:
(0,0) : error 0040: The Type Person is not qualified with a namespace or alias. Only primitive types can be used without qualification.

It's a Code-First project. Very simple. Just a table, and I want to create a function to concat two fields.

    public class Person
    {
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }


    public static class ModelDefinedFunctions
    {
        [ModelDefinedFunction(nameof(FormatName), "DataAccess",
            @"[Person].[FirstName] + N' ' + [Person].[LastName]")]
        public static string FormatName(this Person person) =>
            $"{person.FirstName} {person.LastName}";
    }


    public class MyContext : DbContext
    {
        public MyContext() : base("MyDbContext")
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<MyContext, Configuration>());

        }

        public DbSet<Person> Persons { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.AddFunctions(typeof(ModelDefinedFunctions));
        }
    }

I've set up a demo project to show the error: https://github.com/MikelLuri/EFFunctionsExample
Is it a bug, am I doing something wrong...?

@lojell
Copy link

lojell commented May 20, 2019

Hi, I have the same problem.

@CZEMacLeod
Copy link

Did either of you get anywhere with this? I've hit the same issue in my tests...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants