C
C#13mo ago
hutonahill

✅ using using to clear up ambiguous references.

I've to two method called index: Microsoft.EntityFrameworkCore.Index System.ComponentModel.DataAnnotations.Schema.Index i don't use the 2nd one. I want every mention of index to be interpreted as the first one. I've tried adding one of these using's to fix the problem, but nether works, it just says it Cannot resolve symbol 'Index'
using Index = Microsoft.EntityFrameworkCore.Index;
using IndexCB = System.ComponentModel.DataAnnotations.Schema.Index;
using Index = Microsoft.EntityFrameworkCore.Index;
using IndexCB = System.ComponentModel.DataAnnotations.Schema.Index;
25 Replies
jcotton42
jcotton4213mo ago
Do you need anything from Schema?
Angius
Angius13mo ago
Alternatively: don't use data annotations and go with convention and fluent config
hutonahill
hutonahillOP13mo ago
yep if i dont use data annotations how do i get stuff like strings of limited length?
jcotton42
jcotton4213mo ago
Wait, I don’t see an Index class in Schema in the docs.
Angius
Angius13mo ago
No description
hutonahill
hutonahillOP13mo ago
no idea what that is Got it! its IndexAttribute. not sure why is written different in the code...
jcotton42
jcotton4213mo ago
You can omit the Attribute suffix when using attributes. Wait, is this EF or EF Core?
hutonahill
hutonahillOP13mo ago
Core?
jcotton42
jcotton4213mo ago
Oh jesus it’s from EF6.
Angius
Angius13mo ago
Burn it
Angius
Angius13mo ago
Yeah well throw away this namespace
hutonahill
hutonahillOP13mo ago
i take it there is a better solution
Angius
Angius13mo ago
Yes, don't use anything from this namespace
jcotton42
jcotton4213mo ago
Is this a new or existing app? I forget.
Angius
Angius13mo ago
Or use convention and fluent config
hutonahill
hutonahillOP13mo ago
in development
jcotton42
jcotton4213mo ago
That particular Index attrib isn’t available if you’re using EF Core it seems. Show your csproj.
hutonahill
hutonahillOP13mo ago
and i am still firugint out how to use EF now that its set up. am willing to throw EF out in favor of a better solution
Angius
Angius13mo ago
FYI: EF and EF Core are two different things EF yuck ugly old yuck don't EF Core mmm pretty new mmm yes use
hutonahill
hutonahillOP13mo ago
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="3.15.3"/>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MySql.Data" Version="9.0.0"/>
<PackageReference Include="MySqlConnector" Version="2.3.7" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Otp.NET" Version="1.4.0"/>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2"/>
<PackageReference Include="SQLite.Encryption.Extension" Version="1.0.118.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.2"/>
<PackageReference Include="System.Data.SQLite" Version="1.0.118"/>
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="3.15.3"/>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MySql.Data" Version="9.0.0"/>
<PackageReference Include="MySqlConnector" Version="2.3.7" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Otp.NET" Version="1.4.0"/>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2"/>
<PackageReference Include="SQLite.Encryption.Extension" Version="1.0.118.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.2"/>
<PackageReference Include="System.Data.SQLite" Version="1.0.118"/>
</ItemGroup>
<ItemGroup>
<Folder Include="Data\"/>
<Folder Include="Models\"/>
</ItemGroup>
</Project>
<ItemGroup>
<Folder Include="Data\"/>
<Folder Include="Models\"/>
</ItemGroup>
</Project>
jcotton42
jcotton4213mo ago
Wait, that is EF Core. confused noises
hutonahill
hutonahillOP13mo ago
solved it with this: using Index = Microsoft.EntityFrameworkCore.IndexAttribute; so it is EF core
Angius
Angius13mo ago
Yeah, so just don't use the System.ComponentModel.DataAnnotations.Schema.Index namespace anywhere If you don't have a using with that, and you have using Microsoft.EntityFrameworkCore then only that one will be used
hutonahill
hutonahillOP13mo ago
thats what i am doing right now

Did you find this page helpful?